Explorar o código

refactor(vpn): create and use getter methods for vpn poroto

Mustafa Arici %!s(int64=8) %!d(string=hai) anos
pai
achega
a80d03aff6
Modificáronse 2 ficheiros con 9 adicións e 1 borrados
  1. 1 1
      api/rpc.go
  2. 8 0
      vpn.go

+ 1 - 1
api/rpc.go

@@ -166,7 +166,7 @@ func (s *VPNService) Status(ctx context.Context, req *pb.VPNStatusRequest) (*pb.
 		SerialNumber: server.SerialNumber,
 		Hostname:     server.Hostname,
 		Port:         server.Port,
-		Proto:        server.Proto,
+		Proto:        server.GetProto(),
 		Cert:         server.Cert,
 		CACert:       server.CACert,
 		Net:          server.Net,

+ 8 - 0
vpn.go

@@ -473,6 +473,14 @@ func GetServerInstance() (*DBServer, error) {
 	return &server, nil
 }
 
+// GetProto returns the current VPN proto.
+func (s *DBServer) GetProto() string {
+	if s.Proto != "" {
+		return s.Proto
+	}
+	return UDPProto
+}
+
 // IsInitialized checks if there is a default server in the database or not.
 func IsInitialized() bool {
 	var server DBServer