relay: added private tunnel
This commit is contained in:
@ -48,7 +48,7 @@ func (c *relayConnector) tunnel(ctx context.Context, conn net.Conn, log logger.L
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debugf("create tunnel %s connector %s OK", c.md.tunnelID, cid)
|
||||
log.Debugf("create tunnel %s connector %s OK", c.md.tunnelID.String(), cid)
|
||||
|
||||
session, err := mux.ServerSession(conn)
|
||||
if err != nil {
|
||||
@ -90,7 +90,7 @@ func (c *relayConnector) initTunnel(conn net.Conn) (addr net.Addr, cid relay.Con
|
||||
}
|
||||
|
||||
if resp.Status != relay.StatusOK {
|
||||
err = fmt.Errorf("%d: create tunnel %s failed", resp.Status, c.md.tunnelID)
|
||||
err = fmt.Errorf("%d: create tunnel %s failed", resp.Status, c.md.tunnelID.String())
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -83,11 +83,13 @@ func (c *relayConnector) Connect(ctx context.Context, conn net.Conn, network, ad
|
||||
if err := af.ParseFrom(address); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Features = append(req.Features, af)
|
||||
}
|
||||
|
||||
// forward mode if port is 0.
|
||||
if af.Port > 0 {
|
||||
req.Features = append(req.Features, af)
|
||||
}
|
||||
if !c.md.tunnelID.IsZero() {
|
||||
req.Features = append(req.Features, &relay.TunnelFeature{
|
||||
ID: c.md.tunnelID,
|
||||
})
|
||||
}
|
||||
|
||||
if c.md.noDelay {
|
||||
|
@ -30,7 +30,7 @@ func (c *relayConnector) parseMetadata(md mdata.Metadata) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
copy(c.md.tunnelID[:], uuid[:])
|
||||
c.md.tunnelID = relay.NewTunnelID(uuid[:])
|
||||
}
|
||||
|
||||
return
|
||||
|
Reference in New Issue
Block a user