mirror of
https://github.com/safing/portmaster.git
synced 2026-06-19 20:44:35 +00:00
Allow Portmaster to cooperate with the IVPN client: - Accept IVPN VPN tunnel and service process connections - Delegate DNS control to Portmaster when custom DNS is configured - Auto-connect to IVPN daemon on startup and on ping - Hook into firewall verdict pipeline via new ExtVerdictHandler
42 lines
1004 B
Go
42 lines
1004 B
Go
package interop
|
|
|
|
import (
|
|
"github.com/safing/portmaster/base/api"
|
|
)
|
|
|
|
const (
|
|
APIEndpointPing = "interop/ping"
|
|
)
|
|
|
|
type pingParams struct {
|
|
Message bool `json:"message"`
|
|
}
|
|
|
|
func (i *Interoperability) registerAPIEndpoints() error {
|
|
if err := api.RegisterEndpoint(api.Endpoint{
|
|
Path: APIEndpointPing,
|
|
Read: api.PermitAnyone,
|
|
Write: api.PermitAnyone,
|
|
ActionFunc: i.handlePing,
|
|
Name: "Interoperability: Ping Portmaster",
|
|
Description: "Ping the Portmaster Core Service for interoperability checks.",
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (c *Interoperability) handlePing(r *api.Request) (msg string, err error) {
|
|
// Received ping, possibly from IVPN client
|
|
// Try to connect to IVPN client if not already connected
|
|
|
|
for _, im := range c.interopModules {
|
|
if err := im.PingHandler(); err != nil {
|
|
c.mgr.Warn("Failed to handle ping for interoperability module: " + err.Error())
|
|
}
|
|
}
|
|
|
|
return "", nil
|
|
}
|