mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-09 16:20:26 +00:00
cleanup
This commit is contained in:
parent
5f2bcaa71f
commit
c60dd42baa
@ -103,24 +103,13 @@ func (c *Core) GetSessions() []Session {
|
||||
return sessions
|
||||
}
|
||||
|
||||
// Listen starts a new listener (either TCP or TLS). The input should be a url.URL
|
||||
// parsed from a string of the form e.g. "tcp://a.b.c.d:e". In the case of a
|
||||
// link-local address, the interface should be provided as the second argument.
|
||||
func (c *Core) Listen(u *url.URL, sintf string) (*TcpListener, error) {
|
||||
return c.links.tcp.listenURL(u, sintf)
|
||||
}
|
||||
|
||||
// ListenTCP starts a new TCP listener. The input URI should match that of the
|
||||
// "Listen" configuration item, e.g.
|
||||
// tcp://a.b.c.d:e
|
||||
func (c *Core) xListenTCP(uri string, metric uint8) (*TcpListener, error) {
|
||||
return c.links.tcp.listen(uri, nil, metric)
|
||||
}
|
||||
|
||||
// ListenTLS starts a new TLS listener. The input URI should match that of the
|
||||
// "Listen" configuration item, e.g.
|
||||
// tls://a.b.c.d:e
|
||||
func (c *Core) xListenTLS(uri string, metric uint8) (*TcpListener, error) {
|
||||
return c.links.tcp.listen(uri, c.links.tcp.tls.forListener, metric)
|
||||
}
|
||||
|
||||
// Address gets the IPv6 address of the Yggdrasil node. This is always a /128
|
||||
// address. The IPv6 address is only relevant when the node is operating as an
|
||||
// IP router and often is meaningless when embedded into an application, unless
|
||||
|
@ -113,22 +113,8 @@ func (t *tcp) init(l *links) error {
|
||||
if err != nil {
|
||||
t.links.core.log.Errorln("Failed to parse listener: listener", listenaddr, "is not correctly formatted, ignoring")
|
||||
}
|
||||
var metric uint8 // TODO parse from url
|
||||
if ms := u.Query()["metric"]; len(ms) == 1 {
|
||||
m64, _ := strconv.ParseUint(ms[0], 10, 8)
|
||||
metric = uint8(m64)
|
||||
}
|
||||
switch u.Scheme {
|
||||
case "tcp":
|
||||
if _, err := t.listen(u.Host, nil, metric); err != nil {
|
||||
return err
|
||||
}
|
||||
case "tls":
|
||||
if _, err := t.listen(u.Host, t.tls.forListener, metric); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
t.links.core.log.Errorln("Failed to add listener: listener", u.String(), "is not correctly formatted, ignoring")
|
||||
if _, err := t.listenURL(u, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user