This commit is contained in:
parent
96b57f65ca
commit
cc9d036f43
@ -85,13 +85,23 @@ func buildTcp(p *proxy.Proxy, peer Peer) error {
|
||||
}
|
||||
|
||||
func buildUdp(p *proxy.Proxy, peer Peer) error {
|
||||
var c udp.Congestion
|
||||
switch peer.Congestion {
|
||||
case "None":
|
||||
c = congestion.NewNone()
|
||||
default:
|
||||
fallthrough
|
||||
case "NewReno":
|
||||
c = congestion.NewNewReno()
|
||||
}
|
||||
|
||||
if peer.RemoteHost != "" {
|
||||
f, err := udp.InitiateFlow(
|
||||
fmt.Sprintf("%s:", peer.LocalHost),
|
||||
fmt.Sprintf("%s:%d", peer.RemoteHost, peer.RemotePort),
|
||||
UselessMac{},
|
||||
UselessMac{},
|
||||
congestion.NewNewReno(),
|
||||
c,
|
||||
time.Duration(peer.KeepAlive)*time.Second,
|
||||
)
|
||||
|
||||
@ -110,7 +120,7 @@ func buildUdp(p *proxy.Proxy, peer Peer) error {
|
||||
fmt.Sprintf("%s:%d", peer.LocalHost, peer.LocalPort),
|
||||
UselessMac{},
|
||||
UselessMac{},
|
||||
congestion.NewNewReno(),
|
||||
c,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -24,6 +24,8 @@ type Peer struct {
|
||||
RemoteHost string `validate:"required_with=RemotePort,omitempty,fqdn|ip"`
|
||||
RemotePort uint `validate:"required_with=RemoteHost,omitempty,max=65535"`
|
||||
|
||||
Congestion string `validate:"oneof=NewReno None"`
|
||||
|
||||
KeepAlive uint
|
||||
Timeout uint
|
||||
RetryWait uint
|
||||
|
40
udp/congestion/none.go
Normal file
40
udp/congestion/none.go
Normal file
@ -0,0 +1,40 @@
|
||||
package congestion
|
||||
|
||||
import "time"
|
||||
|
||||
type None struct {
|
||||
sequence chan uint32
|
||||
}
|
||||
|
||||
func NewNone() *None {
|
||||
c := None{
|
||||
sequence: make(chan uint32),
|
||||
}
|
||||
|
||||
go func() {
|
||||
var s uint32
|
||||
for {
|
||||
if s == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
c.sequence <- s
|
||||
s++
|
||||
}
|
||||
}()
|
||||
|
||||
return &c
|
||||
}
|
||||
|
||||
func (c *None) Sequence() uint32 {
|
||||
return <-c.sequence
|
||||
}
|
||||
|
||||
func (c *None) ReceivedPacket(seq uint32) {}
|
||||
func (c *None) ReceivedAck(uint32) {}
|
||||
func (c *None) NextAck() uint32 { return 0 }
|
||||
func (c *None) ReceivedNack(uint32) {}
|
||||
func (c *None) NextNack() uint32 { return 0 }
|
||||
func (c *None) AwaitEarlyUpdate(keepalive time.Duration) {
|
||||
select {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user