diff --git a/main.go b/main.go index e24a551..0e00f0f 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,7 @@ import ( "github.com/spf13/viper" lumberjack "gopkg.in/natefinch/lumberjack.v2" - "git.daplie.com/Daplie/go-rvpn-server/rvpn/genericlistener" + "git.daplie.com/Daplie/go-rvpn-server/rvpn/server" ) var ( @@ -31,7 +31,7 @@ var ( argServerAdminBinding string argServerExternalBinding string argDeadTime int - connectionTable *genericlistener.Table + connectionTable *server.Table secretKey = "abc123" wssHostName = "localhost.daplie.me" adminHostName = "rvpn.daplie.invalid" @@ -71,7 +71,7 @@ func main() { } // send the output io.Writing to the other packages - genericlistener.InitLogging(logoutput) + server.InitLogging(logoutput) loginfo = log.New(logoutput, "INFO: main: ", logFlags) logdebug = log.New(logoutput, "DEBUG: main:", logFlags) @@ -107,12 +107,12 @@ func main() { ctx, cancelContext := context.WithCancel(context.Background()) defer cancelContext() - serverStatus := genericlistener.NewStatus(ctx) + serverStatus := server.NewStatus(ctx) serverStatus.AdminDomain = adminHostName serverStatus.WssDomain = wssHostName serverStatus.Name = serverName serverStatus.StartTime = time.Now() - serverStatus.DeadTime = genericlistener.NewStatusDeadTime(dwell, idle, cancelcheck) + serverStatus.DeadTime = server.NewStatusDeadTime(dwell, idle, cancelcheck) serverStatus.LoadbalanceDefaultMethod = lbDefaultMethod // Setup for GenericListenServe. @@ -124,16 +124,16 @@ func main() { // - if tls, establish, protocol peek buffer, else decrypted // - match protocol - connectionTracking := genericlistener.NewTracking() + connectionTracking := server.NewTracking() serverStatus.ConnectionTracking = connectionTracking go connectionTracking.Run(ctx) - connectionTable = genericlistener.NewTable(dwell, idle) + connectionTable = server.NewTable(dwell, idle) serverStatus.ConnectionTable = connectionTable go connectionTable.Run(ctx, lbDefaultMethod) - genericListeners := genericlistener.NewGenerListeners(ctx, secretKey, certbundle, serverStatus) - serverStatus.GenericListeners = genericListeners + genericListeners := server.NewGenerListeners(ctx, secretKey, certbundle, serverStatus) + //serverStatus.GenericListeners = genericListeners go genericListeners.Run(ctx, argGenericBinding) diff --git a/rvpn/genericlistener/api_collect_connections.go b/rvpn/server/api_collect_connections.go similarity index 94% rename from rvpn/genericlistener/api_collect_connections.go rename to rvpn/server/api_collect_connections.go index 4b113f1..f0201e3 100644 --- a/rvpn/genericlistener/api_collect_connections.go +++ b/rvpn/server/api_collect_connections.go @@ -1,4 +1,4 @@ -package genericlistener +package server //ConnectionStatsAPI -- type ConnectionStatsAPI struct { diff --git a/rvpn/genericlistener/api_collect_domains.go b/rvpn/server/api_collect_domains.go similarity index 98% rename from rvpn/genericlistener/api_collect_domains.go rename to rvpn/server/api_collect_domains.go index b08d863..1fe974a 100644 --- a/rvpn/genericlistener/api_collect_domains.go +++ b/rvpn/server/api_collect_domains.go @@ -1,4 +1,4 @@ -package genericlistener +package server //DomainsAPI -- A collections of all the domains //List of Domains -> DomainAPI diff --git a/rvpn/genericlistener/api_collect_server.go b/rvpn/server/api_collect_server.go similarity index 97% rename from rvpn/genericlistener/api_collect_server.go rename to rvpn/server/api_collect_server.go index 9b9cd23..7cfea54 100644 --- a/rvpn/genericlistener/api_collect_server.go +++ b/rvpn/server/api_collect_server.go @@ -1,4 +1,4 @@ -package genericlistener +package server import "time" diff --git a/rvpn/genericlistener/api_collect_server_domains.go b/rvpn/server/api_collect_server_domains.go similarity index 98% rename from rvpn/genericlistener/api_collect_server_domains.go rename to rvpn/server/api_collect_server_domains.go index 3a9b84c..426a68f 100644 --- a/rvpn/genericlistener/api_collect_server_domains.go +++ b/rvpn/server/api_collect_server_domains.go @@ -1,4 +1,4 @@ -package genericlistener +package server //ServerDomainsAPI -- Structure to support the server API type ServerDomainsAPI struct { diff --git a/rvpn/genericlistener/api_collect_servers.go b/rvpn/server/api_collect_servers.go similarity index 98% rename from rvpn/genericlistener/api_collect_servers.go rename to rvpn/server/api_collect_servers.go index ed5b47c..302df90 100644 --- a/rvpn/genericlistener/api_collect_servers.go +++ b/rvpn/server/api_collect_servers.go @@ -1,4 +1,4 @@ -package genericlistener +package server import "time" diff --git a/rvpn/genericlistener/api_collect_status.go b/rvpn/server/api_collect_status.go similarity index 98% rename from rvpn/genericlistener/api_collect_status.go rename to rvpn/server/api_collect_status.go index 2104b22..f796d7f 100644 --- a/rvpn/genericlistener/api_collect_status.go +++ b/rvpn/server/api_collect_status.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "time" diff --git a/rvpn/genericlistener/api_collect_status_dead time.go b/rvpn/server/api_collect_status_dead time.go similarity index 94% rename from rvpn/genericlistener/api_collect_status_dead time.go rename to rvpn/server/api_collect_status_dead time.go index 4161774..75c9221 100644 --- a/rvpn/genericlistener/api_collect_status_dead time.go +++ b/rvpn/server/api_collect_status_dead time.go @@ -1,4 +1,4 @@ -package genericlistener +package server //StatusDeadTimeAPI -- structure for deadtime configuration type StatusDeadTimeAPI struct { diff --git a/rvpn/genericlistener/api_collect_status_traffic.go b/rvpn/server/api_collect_status_traffic.go similarity index 93% rename from rvpn/genericlistener/api_collect_status_traffic.go rename to rvpn/server/api_collect_status_traffic.go index ff6ccd9..60692f8 100644 --- a/rvpn/genericlistener/api_collect_status_traffic.go +++ b/rvpn/server/api_collect_status_traffic.go @@ -1,4 +1,4 @@ -package genericlistener +package server //TrafficStats -- type TrafficAPI struct { diff --git a/rvpn/genericlistener/api_interface.go b/rvpn/server/api_interface.go similarity index 99% rename from rvpn/genericlistener/api_interface.go rename to rvpn/server/api_interface.go index 19690ba..108d1c7 100644 --- a/rvpn/genericlistener/api_interface.go +++ b/rvpn/server/api_interface.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "context" diff --git a/rvpn/genericlistener/conn_tracking.go b/rvpn/server/conn_tracking.go similarity index 98% rename from rvpn/genericlistener/conn_tracking.go rename to rvpn/server/conn_tracking.go index a89de9e..7acfb7c 100644 --- a/rvpn/genericlistener/conn_tracking.go +++ b/rvpn/server/conn_tracking.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "context" diff --git a/rvpn/genericlistener/conn_wedge.go b/rvpn/server/conn_wedge.go similarity index 98% rename from rvpn/genericlistener/conn_wedge.go rename to rvpn/server/conn_wedge.go index 8cd7d8f..b94ff09 100644 --- a/rvpn/genericlistener/conn_wedge.go +++ b/rvpn/server/conn_wedge.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "bufio" diff --git a/rvpn/genericlistener/connection.go b/rvpn/server/connection.go similarity index 99% rename from rvpn/genericlistener/connection.go rename to rvpn/server/connection.go index d1045de..a2ab6f2 100755 --- a/rvpn/genericlistener/connection.go +++ b/rvpn/server/connection.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "context" diff --git a/rvpn/genericlistener/connection_registration.go b/rvpn/server/connection_registration.go similarity index 97% rename from rvpn/genericlistener/connection_registration.go rename to rvpn/server/connection_registration.go index 66a0f87..1d5f373 100644 --- a/rvpn/genericlistener/connection_registration.go +++ b/rvpn/server/connection_registration.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "github.com/gorilla/websocket" diff --git a/rvpn/genericlistener/connection_table.go b/rvpn/server/connection_table.go similarity index 99% rename from rvpn/genericlistener/connection_table.go rename to rvpn/server/connection_table.go index b98495f..4dac70a 100755 --- a/rvpn/genericlistener/connection_table.go +++ b/rvpn/server/connection_table.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "context" diff --git a/rvpn/genericlistener/domain_loadbalance.go b/rvpn/server/domain_loadbalance.go similarity index 99% rename from rvpn/genericlistener/domain_loadbalance.go rename to rvpn/server/domain_loadbalance.go index ccbef20..59f58df 100644 --- a/rvpn/genericlistener/domain_loadbalance.go +++ b/rvpn/server/domain_loadbalance.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "fmt" diff --git a/rvpn/genericlistener/domain_mapping.go b/rvpn/server/domain_mapping.go similarity index 95% rename from rvpn/genericlistener/domain_mapping.go rename to rvpn/server/domain_mapping.go index 7c3b49b..8f8be8b 100644 --- a/rvpn/genericlistener/domain_mapping.go +++ b/rvpn/server/domain_mapping.go @@ -1,4 +1,4 @@ -package genericlistener +package server //DomainMapping -- type DomainMapping struct { diff --git a/rvpn/genericlistener/domain_track.go b/rvpn/server/domain_track.go similarity index 97% rename from rvpn/genericlistener/domain_track.go rename to rvpn/server/domain_track.go index febf068..89be377 100644 --- a/rvpn/genericlistener/domain_track.go +++ b/rvpn/server/domain_track.go @@ -1,4 +1,4 @@ -package genericlistener +package server //DomainTrack -- Tracking specifics for domains type DomainTrack struct { diff --git a/rvpn/genericlistener/listener_generic.go b/rvpn/server/listener_generic.go similarity index 99% rename from rvpn/genericlistener/listener_generic.go rename to rvpn/server/listener_generic.go index d239951..ad56bdc 100644 --- a/rvpn/genericlistener/listener_generic.go +++ b/rvpn/server/listener_generic.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "bufio" diff --git a/rvpn/genericlistener/manager.go b/rvpn/server/manager.go similarity index 92% rename from rvpn/genericlistener/manager.go rename to rvpn/server/manager.go index f9e4a37..17a6b20 100644 --- a/rvpn/genericlistener/manager.go +++ b/rvpn/server/manager.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "context" @@ -43,8 +43,8 @@ func NewListenerRegistration(port int) (p *ListenerRegistration) { return } -//GenericListeners - -type GenericListeners struct { +//servers - +type servers struct { listeners map[*net.Listener]int ctx context.Context connnectionTable *Table @@ -52,7 +52,7 @@ type GenericListeners struct { secretKey string certbundle tls.Certificate register chan *ListenerRegistration - genericListeners *GenericListeners + servers *servers wssHostName string adminHostName string cancelCheck int @@ -61,8 +61,8 @@ type GenericListeners struct { } //NewGenerListeners -- -func NewGenerListeners(ctx context.Context, secretKey string, certbundle tls.Certificate, serverStatus *Status) (p *GenericListeners) { - p = new(GenericListeners) +func NewGenerListeners(ctx context.Context, secretKey string, certbundle tls.Certificate, serverStatus *Status) (p *servers) { + p = new(servers) p.listeners = make(map[*net.Listener]int) p.ctx = ctx p.connnectionTable = serverStatus.ConnectionTable @@ -81,7 +81,7 @@ func NewGenerListeners(ctx context.Context, secretKey string, certbundle tls.Cer //Run -- Execute // - execute the GenericLister // - pass initial port, we'll announce that -func (gl *GenericListeners) Run(ctx context.Context, initialPort int) { +func (gl *servers) Run(ctx context.Context, initialPort int) { loginfo.Println("ConnectionTable starting") config := &tls.Config{Certificates: []tls.Certificate{gl.certbundle}} diff --git a/rvpn/genericlistener/one_conn.go b/rvpn/server/one_conn.go similarity index 95% rename from rvpn/genericlistener/one_conn.go rename to rvpn/server/one_conn.go index ffc17cd..9ced6a5 100644 --- a/rvpn/genericlistener/one_conn.go +++ b/rvpn/server/one_conn.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "io" diff --git a/rvpn/genericlistener/send_track.go b/rvpn/server/send_track.go similarity index 92% rename from rvpn/genericlistener/send_track.go rename to rvpn/server/send_track.go index 817a179..98352f4 100644 --- a/rvpn/genericlistener/send_track.go +++ b/rvpn/server/send_track.go @@ -1,4 +1,4 @@ -package genericlistener +package server //SendTrack -- Used as a channel communication to id domain asssociated to domain for outbound WSS type SendTrack struct { diff --git a/rvpn/genericlistener/setup.go b/rvpn/server/setup.go similarity index 78% rename from rvpn/genericlistener/setup.go rename to rvpn/server/setup.go index c57d333..c906f8a 100644 --- a/rvpn/genericlistener/setup.go +++ b/rvpn/server/setup.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "io" @@ -15,8 +15,8 @@ var ( ) func init() { - loginfo = log.New(os.Stdout, "INFO: genericlistener: ", logFlags) - logdebug = log.New(os.Stdout, "DEBUG: genericlistener:", logFlags) + loginfo = log.New(os.Stdout, "INFO: server: ", logFlags) + logdebug = log.New(os.Stdout, "DEBUG: server:", logFlags) connectionID = 0 } diff --git a/rvpn/genericlistener/status.go b/rvpn/server/status.go similarity index 96% rename from rvpn/genericlistener/status.go rename to rvpn/server/status.go index 1cd3369..6a7275e 100644 --- a/rvpn/genericlistener/status.go +++ b/rvpn/server/status.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "context" @@ -15,7 +15,7 @@ type Status struct { DeadTime *StatusDeadTime ConnectionTracking *Tracking ConnectionTable *Table - GenericListeners *GenericListeners + servers *servers LoadbalanceDefaultMethod string AdminStats *TrafficStats AdminReqTyoe *AdminReqType diff --git a/rvpn/genericlistener/status_dead_time.go b/rvpn/server/status_dead_time.go similarity index 93% rename from rvpn/genericlistener/status_dead_time.go rename to rvpn/server/status_dead_time.go index f68a9c9..c53672a 100644 --- a/rvpn/genericlistener/status_dead_time.go +++ b/rvpn/server/status_dead_time.go @@ -1,4 +1,4 @@ -package genericlistener +package server //StatusDeadTime -- structure for deadtime configuration type StatusDeadTime struct { diff --git a/rvpn/genericlistener/status_req_type.go b/rvpn/server/status_req_type.go similarity index 97% rename from rvpn/genericlistener/status_req_type.go rename to rvpn/server/status_req_type.go index 9d4944c..c1b7d32 100644 --- a/rvpn/genericlistener/status_req_type.go +++ b/rvpn/server/status_req_type.go @@ -1,4 +1,4 @@ -package genericlistener +package server import "sync" diff --git a/rvpn/genericlistener/status_traffic_connections.go b/rvpn/server/status_traffic_connections.go similarity index 95% rename from rvpn/genericlistener/status_traffic_connections.go rename to rvpn/server/status_traffic_connections.go index f412725..47131db 100644 --- a/rvpn/genericlistener/status_traffic_connections.go +++ b/rvpn/server/status_traffic_connections.go @@ -1,4 +1,4 @@ -package genericlistener +package server //ConnectionStats -- type ConnectionStats struct { diff --git a/rvpn/genericlistener/status_traffic_stats.go b/rvpn/server/status_traffic_stats.go similarity index 96% rename from rvpn/genericlistener/status_traffic_stats.go rename to rvpn/server/status_traffic_stats.go index 2d1fad9..2a19a0b 100644 --- a/rvpn/genericlistener/status_traffic_stats.go +++ b/rvpn/server/status_traffic_stats.go @@ -1,4 +1,4 @@ -package genericlistener +package server //TrafficStats -- type TrafficStats struct { diff --git a/rvpn/genericlistener/tls_get_hello.go b/rvpn/server/tls_get_hello.go similarity index 98% rename from rvpn/genericlistener/tls_get_hello.go rename to rvpn/server/tls_get_hello.go index 4e45611..8aa78c4 100644 --- a/rvpn/genericlistener/tls_get_hello.go +++ b/rvpn/server/tls_get_hello.go @@ -1,4 +1,4 @@ -package genericlistener +package server import ( "errors"