merge develop into master #21

Merged
JakeHillion merged 149 commits from develop into master 2021-05-12 00:22:59 +01:00
3 changed files with 9 additions and 8 deletions
Showing only changes of commit 151b608b9b - Show all commits

View File

@ -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(),

View File

@ -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
}

View File

@ -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
}