This commit is contained in:
parent
c331a323a2
commit
151b608b9b
@ -72,7 +72,7 @@ func (c Configuration) Build() (*proxy.Proxy, error) {
|
||||
func buildTcp(p *proxy.Proxy, peer Peer, g func() proxy.MacGenerator, v func() proxy.MacVerifier) error {
|
||||
if peer.RemoteHost != "" {
|
||||
f, err := tcp.InitiateFlow(
|
||||
fmt.Sprintf("%s:", peer.GetLocalHost()),
|
||||
func() string { return fmt.Sprintf("%s:", peer.GetLocalHost()) },
|
||||
fmt.Sprintf("%s:%d", peer.RemoteHost, peer.RemotePort),
|
||||
)
|
||||
|
||||
@ -107,7 +107,7 @@ func buildUdp(p *proxy.Proxy, peer Peer, g func() proxy.MacGenerator, v func() p
|
||||
|
||||
if peer.RemoteHost != "" {
|
||||
f, err := udp.InitiateFlow(
|
||||
fmt.Sprintf("%s:", peer.GetLocalHost()),
|
||||
func() string { return fmt.Sprintf("%s:", peer.GetLocalHost()) },
|
||||
fmt.Sprintf("%s:%d", peer.RemoteHost, peer.RemotePort),
|
||||
v(),
|
||||
g(),
|
||||
|
@ -22,7 +22,7 @@ type Conn interface {
|
||||
}
|
||||
|
||||
type InitiatedFlow struct {
|
||||
Local string
|
||||
Local func() string
|
||||
Remote string
|
||||
|
||||
mu sync.RWMutex
|
||||
@ -43,7 +43,7 @@ func (f Flow) String() string {
|
||||
return fmt.Sprintf("TcpInbound{%v -> %v}", f.conn.RemoteAddr(), f.conn.LocalAddr())
|
||||
}
|
||||
|
||||
func InitiateFlow(local, remote string) (*InitiatedFlow, error) {
|
||||
func InitiateFlow(local func() string, remote string) (*InitiatedFlow, error) {
|
||||
f := InitiatedFlow{
|
||||
Local: local,
|
||||
Remote: remote,
|
||||
@ -60,7 +60,7 @@ func (f *InitiatedFlow) Reconnect() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
localAddr, err := net.ResolveTCPAddr("tcp", f.Local)
|
||||
localAddr, err := net.ResolveTCPAddr("tcp", f.Local())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ type PacketConn interface {
|
||||
}
|
||||
|
||||
type InitiatedFlow struct {
|
||||
Local string
|
||||
Local func() string
|
||||
Remote string
|
||||
|
||||
g proxy.MacGenerator
|
||||
@ -55,7 +55,8 @@ func (f Flow) String() string {
|
||||
}
|
||||
|
||||
func InitiateFlow(
|
||||
local, remote string,
|
||||
local func() string,
|
||||
remote string,
|
||||
v proxy.MacVerifier,
|
||||
g proxy.MacGenerator,
|
||||
c Congestion,
|
||||
@ -88,7 +89,7 @@ func (f *InitiatedFlow) Reconnect() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
localAddr, err := net.ResolveUDPAddr("udp", f.Local)
|
||||
localAddr, err := net.ResolveUDPAddr("udp", f.Local())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user