mirror of
https://github.com/therootcompany/telebit.git
synced 2025-12-25 14:58:46 +00:00
- debugging issues (not resolved) attempting to move the main executable into the base directory, this did not solve the issue, keeping it here. A main.go and the executable. listener_client — the WSS client - removed support for anything admin - injected the domains from the claim - domains are now included as initialDomains - registration performans as normal but includes adding the domains to a map of domains, and a collection of domains on the connection. - the system now supports look up fast in either direction, not sure if it will be needed. - reads a chan during registration before allowing traffic, making sure all is well. - registration returns a true on the channel if all is well. If it is not, false. Likely will add some text to pass back. Connection - added support for boolean channel - support for initial domains in a slice, these are brought back from the JWT as a interface and then are type asserted into the map - removed all the old timer sender dwell stuff as a POC for traffic counts. ConnectionTable - added support for domain announcement after the WSS is connection. Not sure if we will need these. They have not been implemented. - I assume all domains are registered with JWT unless I hear differently which would require a new WSS session - expanded NewTable constructor - populating domains into the domain map, and into the connection slice. - added support for removing domains when a connection is removed.
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package xlate
|
|
|
|
import "golang.org/x/net/websocket"
|
|
|
|
const (
|
|
initialDomains = 10
|
|
incrementDomains = 10
|
|
)
|
|
|
|
type domain string
|
|
|
|
//WssRegistration --
|
|
type WssRegistration struct {
|
|
domainName domain
|
|
connection *websocket.Conn
|
|
}
|
|
|
|
//WssMapping --
|
|
type WssMapping struct {
|
|
register chan *websocket.Conn
|
|
unregister chan *websocket.Conn
|
|
domainRegister chan *WssRegistration
|
|
domainUnregister chan *WssRegistration
|
|
connections map[*websocket.Conn][]domain
|
|
domains map[domain]*websocket.Conn
|
|
}
|
|
|
|
//NewwssMapping -- constructor
|
|
func NewwssMapping() (p *WssMapping) {
|
|
p = new(WssMapping)
|
|
p.connections = make(map[*websocket.Conn][]domain)
|
|
return
|
|
}
|
|
|
|
//Run -- Execute
|
|
func (c *WssMapping) Run() {
|
|
loginfo.Println("WSSMapping starting")
|
|
for {
|
|
select {
|
|
case wssConn := <-c.register:
|
|
loginfo.Println("register fired")
|
|
c.connections[wssConn] = make([]domain, initialDomains)
|
|
|
|
for conn := range c.connections {
|
|
loginfo.Println(conn)
|
|
}
|
|
|
|
case wssConn := <-c.unregister:
|
|
loginfo.Println("closing connection ", wssConn)
|
|
if _, ok := c.connections[wssConn]; ok {
|
|
delete(c.connections, wssConn)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// register a wss connection first -- initialize the domain slice
|
|
// add a domain
|
|
// find the connectino add to the slice.
|
|
// find the domain set the connection in the map.
|
|
|
|
// domain(s) -> connection
|
|
// connection -> domains
|