Add a message type to the tunnel
This commit is contained in:
parent
dfbd730b8c
commit
f848041c49
@ -170,6 +170,9 @@ func (t *tun) process() {
|
|||||||
newMsg.Header[k] = v
|
newMsg.Header[k] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set message head
|
||||||
|
newMsg.Header["Micro-Tunnel"] = "message"
|
||||||
|
|
||||||
// set the tunnel id on the outgoing message
|
// set the tunnel id on the outgoing message
|
||||||
newMsg.Header["Micro-Tunnel-Id"] = msg.id
|
newMsg.Header["Micro-Tunnel-Id"] = msg.id
|
||||||
|
|
||||||
@ -229,6 +232,8 @@ func (t *tun) listen(link *link) {
|
|||||||
if token == t.token {
|
if token == t.token {
|
||||||
link.loopback = true
|
link.loopback = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nothing more to do
|
||||||
continue
|
continue
|
||||||
case "close":
|
case "close":
|
||||||
log.Debugf("Tunnel link %s closing connection", link.Remote())
|
log.Debugf("Tunnel link %s closing connection", link.Remote())
|
||||||
@ -239,8 +244,17 @@ func (t *tun) listen(link *link) {
|
|||||||
log.Debugf("Tunnel link %s received keepalive", link.Remote())
|
log.Debugf("Tunnel link %s received keepalive", link.Remote())
|
||||||
link.lastKeepAlive = time.Now()
|
link.lastKeepAlive = time.Now()
|
||||||
continue
|
continue
|
||||||
|
case "message":
|
||||||
|
// process message
|
||||||
|
log.Debugf("Received %+v from %s", msg, link.Remote())
|
||||||
|
default:
|
||||||
|
// blackhole it
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// strip message header
|
||||||
|
delete(msg.Header, "Micro-Tunnel")
|
||||||
|
|
||||||
// the tunnel id
|
// the tunnel id
|
||||||
id := msg.Header["Micro-Tunnel-Id"]
|
id := msg.Header["Micro-Tunnel-Id"]
|
||||||
delete(msg.Header, "Micro-Tunnel-Id")
|
delete(msg.Header, "Micro-Tunnel-Id")
|
||||||
@ -249,6 +263,9 @@ func (t *tun) listen(link *link) {
|
|||||||
session := msg.Header["Micro-Tunnel-Session"]
|
session := msg.Header["Micro-Tunnel-Session"]
|
||||||
delete(msg.Header, "Micro-Tunnel-Session")
|
delete(msg.Header, "Micro-Tunnel-Session")
|
||||||
|
|
||||||
|
// strip token header
|
||||||
|
delete(msg.Header, "Micro-Tunnel-Token")
|
||||||
|
|
||||||
// if the session id is blank there's nothing we can do
|
// if the session id is blank there's nothing we can do
|
||||||
// TODO: check this is the case, is there any reason
|
// TODO: check this is the case, is there any reason
|
||||||
// why we'd have a blank session? Is the tunnel
|
// why we'd have a blank session? Is the tunnel
|
||||||
@ -260,8 +277,6 @@ func (t *tun) listen(link *link) {
|
|||||||
var s *socket
|
var s *socket
|
||||||
var exists bool
|
var exists bool
|
||||||
|
|
||||||
log.Debugf("Received %+v from %s", msg, link.Remote())
|
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case link.loopback:
|
case link.loopback:
|
||||||
s, exists = t.getSocket(id, "listener")
|
s, exists = t.getSocket(id, "listener")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user