ServerName is now 1st domain in token. Awaiting new token structure for true ServerName.
This commit is contained in:
parent
f809794f22
commit
41adbfaef5
|
@ -1,9 +1,6 @@
|
||||||
package genericlistener
|
package genericlistener
|
||||||
|
|
||||||
import (
|
import "time"
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
//ServerAPI -- Structure to support the server API
|
//ServerAPI -- Structure to support the server API
|
||||||
type ServerAPI struct {
|
type ServerAPI struct {
|
||||||
|
@ -20,7 +17,7 @@ type ServerAPI struct {
|
||||||
//NewServerAPI - Constructor
|
//NewServerAPI - Constructor
|
||||||
func NewServerAPI(c *Connection) (s *ServerAPI) {
|
func NewServerAPI(c *Connection) (s *ServerAPI) {
|
||||||
s = new(ServerAPI)
|
s = new(ServerAPI)
|
||||||
s.ServerName = fmt.Sprintf("%p", c)
|
s.ServerName = c.ServerName()
|
||||||
s.ServerID = c.ConnectionID()
|
s.ServerID = c.ConnectionID()
|
||||||
s.Domains = make([]*DomainAPI, 0)
|
s.Domains = make([]*DomainAPI, 0)
|
||||||
s.Duration = time.Since(c.ConnectTime()).Seconds()
|
s.Duration = time.Since(c.ConnectTime()).Seconds()
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package genericlistener
|
package genericlistener
|
||||||
|
|
||||||
import (
|
import "time"
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
//ServersAPI -- Structure to support the server API
|
//ServersAPI -- Structure to support the server API
|
||||||
type ServersAPI struct {
|
type ServersAPI struct {
|
||||||
|
@ -22,7 +19,7 @@ type ServersAPI struct {
|
||||||
//NewServersAPI - Constructor
|
//NewServersAPI - Constructor
|
||||||
func NewServersAPI(c *Connection) (s *ServersAPI) {
|
func NewServersAPI(c *Connection) (s *ServersAPI) {
|
||||||
s = new(ServersAPI)
|
s = new(ServersAPI)
|
||||||
s.ServerName = fmt.Sprintf("%p", c)
|
s.ServerName = c.ServerName()
|
||||||
s.ServerID = c.ConnectionID()
|
s.ServerID = c.ConnectionID()
|
||||||
s.Domains = make([]*DomainAPI, 0)
|
s.Domains = make([]*DomainAPI, 0)
|
||||||
s.Duration = time.Since(c.ConnectTime()).Seconds()
|
s.Duration = time.Since(c.ConnectTime()).Seconds()
|
||||||
|
|
|
@ -39,6 +39,9 @@ type Connection struct {
|
||||||
// Address of the Remote End Point
|
// Address of the Remote End Point
|
||||||
source string
|
source string
|
||||||
|
|
||||||
|
// serverName -- Name of the server, at this point 1st domain registered. Will likely change with JWT
|
||||||
|
serverName string
|
||||||
|
|
||||||
// bytes in
|
// bytes in
|
||||||
bytesIn int64
|
bytesIn int64
|
||||||
|
|
||||||
|
@ -70,13 +73,15 @@ type Connection struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
//NewConnection -- Constructor
|
//NewConnection -- Constructor
|
||||||
func NewConnection(connectionTable *Table, conn *websocket.Conn, remoteAddress string, initialDomains []interface{}, connectionTrack *Tracking) (p *Connection) {
|
func NewConnection(connectionTable *Table, conn *websocket.Conn, remoteAddress string,
|
||||||
|
initialDomains []interface{}, connectionTrack *Tracking, serverName string) (p *Connection) {
|
||||||
connectionID = connectionID + 1
|
connectionID = connectionID + 1
|
||||||
|
|
||||||
p = new(Connection)
|
p = new(Connection)
|
||||||
p.connectionTable = connectionTable
|
p.connectionTable = connectionTable
|
||||||
p.conn = conn
|
p.conn = conn
|
||||||
p.source = remoteAddress
|
p.source = remoteAddress
|
||||||
|
p.serverName = serverName
|
||||||
p.bytesIn = 0
|
p.bytesIn = 0
|
||||||
p.bytesOut = 0
|
p.bytesOut = 0
|
||||||
p.requests = 0
|
p.requests = 0
|
||||||
|
@ -103,6 +108,16 @@ func (c *Connection) AddTrackedDomain(domain string) {
|
||||||
c.DomainTrack[domain] = p
|
c.DomainTrack[domain] = p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ServerName -- Property
|
||||||
|
func (c *Connection) ServerName() string {
|
||||||
|
return c.serverName
|
||||||
|
}
|
||||||
|
|
||||||
|
//SetServerName -- Setter
|
||||||
|
func (c *Connection) SetServerName(serverName string) {
|
||||||
|
c.serverName = serverName
|
||||||
|
}
|
||||||
|
|
||||||
//InitialDomains -- Property
|
//InitialDomains -- Property
|
||||||
func (c *Connection) InitialDomains() []interface{} {
|
func (c *Connection) InitialDomains() []interface{} {
|
||||||
return c.initialDomains
|
return c.initialDomains
|
||||||
|
|
|
@ -14,6 +14,9 @@ type Registration struct {
|
||||||
// Address of the Remote End Point
|
// Address of the Remote End Point
|
||||||
source string
|
source string
|
||||||
|
|
||||||
|
// serverName
|
||||||
|
serverName string
|
||||||
|
|
||||||
// communications channel between go routines
|
// communications channel between go routines
|
||||||
commCh chan bool
|
commCh chan bool
|
||||||
|
|
||||||
|
@ -24,10 +27,11 @@ type Registration struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
//NewRegistration -- Constructor
|
//NewRegistration -- Constructor
|
||||||
func NewRegistration(conn *websocket.Conn, remoteAddress string, initialDomains []interface{}, connectionTrack *Tracking) (p *Registration) {
|
func NewRegistration(conn *websocket.Conn, remoteAddress string, initialDomains []interface{}, connectionTrack *Tracking, serverName string) (p *Registration) {
|
||||||
p = new(Registration)
|
p = new(Registration)
|
||||||
p.conn = conn
|
p.conn = conn
|
||||||
p.source = remoteAddress
|
p.source = remoteAddress
|
||||||
|
p.serverName = serverName
|
||||||
p.commCh = make(chan bool)
|
p.commCh = make(chan bool)
|
||||||
p.initialDomains = initialDomains
|
p.initialDomains = initialDomains
|
||||||
p.connectionTrack = connectionTrack
|
p.connectionTrack = connectionTrack
|
||||||
|
|
|
@ -103,7 +103,8 @@ func (c *Table) Run(ctx context.Context, defaultMethod string) {
|
||||||
case registration := <-c.register:
|
case registration := <-c.register:
|
||||||
loginfo.Println("register fired")
|
loginfo.Println("register fired")
|
||||||
|
|
||||||
connection := NewConnection(c, registration.conn, registration.source, registration.initialDomains, registration.connectionTrack)
|
connection := NewConnection(c, registration.conn, registration.source, registration.initialDomains,
|
||||||
|
registration.connectionTrack, registration.serverName)
|
||||||
c.connections[connection] = make([]string, initialDomains)
|
c.connections[connection] = make([]string, initialDomains)
|
||||||
registration.commCh <- true
|
registration.commCh <- true
|
||||||
|
|
||||||
|
|
|
@ -382,10 +382,9 @@ func handleWssClient(ctx context.Context, oneConn *oneConnListener) {
|
||||||
|
|
||||||
loginfo.Println("before connection table")
|
loginfo.Println("before connection table")
|
||||||
|
|
||||||
//newConnection := connection.NewConnection(connectionTable, conn, r.RemoteAddr, domains)
|
serverName := domains[0].(string)
|
||||||
|
|
||||||
//connectionTrack := ctx.Value(ctxConnectionTrack).(*Tracking)
|
newRegistration := NewRegistration(conn, r.RemoteAddr, domains, serverStatus.ConnectionTracking, serverName)
|
||||||
newRegistration := NewRegistration(conn, r.RemoteAddr, domains, serverStatus.ConnectionTracking)
|
|
||||||
serverStatus.WSSConnectionRegister(newRegistration)
|
serverStatus.WSSConnectionRegister(newRegistration)
|
||||||
|
|
||||||
ok = <-newRegistration.CommCh()
|
ok = <-newRegistration.CommCh()
|
||||||
|
|
Loading…
Reference in New Issue