tidy up some things, add a destination parameter

This commit is contained in:
idk
2019-03-14 22:56:32 -04:00
parent 4b77bc4d02
commit e5c90d06eb
2 changed files with 12 additions and 6 deletions

View File

@ -31,13 +31,11 @@ func (c *Client) DialContext(ctx context.Context, network, addr string) (net.Con
}
func (c Client) dialCheck(addr string) (int32, bool) {
fmt.Println("DIAL CHECK")
if c.lastaddr == "invalid" {
fmt.Println("Preparing to dial new address.")
return c.NewID(), true
}
fmt.Println("No new address to dial.")
return c.NewID(), false
return c.id, false
}
// Dial implements the net.Dial function and can be used for http.Transport
@ -51,10 +49,9 @@ func (c *Client) Dial(network, addr string) (net.Conn, error) {
return nil, err
}
var id int32
var test bool
if id, test = c.dialCheck(addr); test == true {
c.destination, err = c.CreateStreamSession(id, "")
if c.id, test = c.dialCheck(addr); test == true {
c.destination, err = c.CreateStreamSession(c.id, c.destination)
if err != nil {
return nil, err
}

View File

@ -62,6 +62,15 @@ func SetHost(s string) func(*Client) error {
}
}
//SetLocalDestination sets the local destination of the tunnel from a private
//key
func SetLocalDestination(s string) func(*Client) error {
return func(c *Client) error {
c.destination = s
return nil
}
}
func setlastaddr(s string) func(*Client) error {
return func(c *Client) error {
c.lastaddr = s