Skip to content

Commit

Permalink
Remove unused message types from Unix Socket API
Browse files Browse the repository at this point in the history
Signed-off-by: hwipl <33433250+hwipl@users.noreply.github.com>
  • Loading branch information
hwipl committed May 28, 2023
1 parent 9b5323f commit 0042ed0
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 40 deletions.
3 changes: 0 additions & 3 deletions internal/api/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ const (
TypeNone = iota
TypeOK
TypeError
TypeVPNConnect
TypeVPNDisconnect
TypeVPNQuery
TypeVPNConfigUpdate
TypeUndefined
)
Expand Down
2 changes: 0 additions & 2 deletions internal/api/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ func TestNewMessage(t *testing.T) {
TypeNone,
TypeOK,
TypeError,
TypeVPNConnect,
TypeVPNQuery,
TypeVPNConfigUpdate,
TypeUndefined,
} {
Expand Down
7 changes: 2 additions & 5 deletions internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ func (s *Server) handleRequest(conn net.Conn) {

// check if its a known message type
switch msg.Type {
case TypeVPNConnect:
case TypeVPNDisconnect:
case TypeVPNQuery:
case TypeVPNConfigUpdate:
default:
// send Error and disconnect
Expand Down Expand Up @@ -120,8 +117,8 @@ func (s *Server) Start() {
}
s.listen = listen

// make sure everyone can access the sock file
if err := os.Chmod(s.sockFile, 0777); err != nil {
// make sure only we can access the sock file
if err := os.Chmod(s.sockFile, 0700); err != nil {
log.WithError(err).Error("Daemon could not set permissions of sock file")
}

Expand Down
30 changes: 0 additions & 30 deletions internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,6 @@ func (d *Daemon) disconnectVPN() {
d.runner.Disconnect()
}

// sendVPNStatus sends the VPN status back to the client
func (d *Daemon) sendVPNStatus(request *api.Request) {
// send OK with VPN status
b, err := d.status.JSON()
if err != nil {
log.WithError(err).Fatal("Daemon could not convert status to JSON")
}
request.Reply(b)
}

// setupRouting sets up routing using config
// TODO: move somewhere else?
func (d *Daemon) setupRouting(config *vpnconfig.Config) {
Expand Down Expand Up @@ -412,26 +402,6 @@ func (d *Daemon) handleClientRequest(request *api.Request) {
log.Debug("Daemon handling client request")

switch request.Type() {
case api.TypeVPNConnect:
// parse login info
login, err := logininfo.LoginInfoFromJSON(request.Data())
if err != nil {
log.WithError(err).Error("Daemon could not parse login info JSON")
request.Error("invalid login info in connect message")
break
}

// connect VPN
d.connectVPN(login)

case api.TypeVPNDisconnect:
// diconnect VPN
d.disconnectVPN()

case api.TypeVPNQuery:
// send vpn status
d.sendVPNStatus(request)

case api.TypeVPNConfigUpdate:
// update VPN config
d.updateVPNConfig(request)
Expand Down

0 comments on commit 0042ed0

Please sign in to comment.