mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Improve api firewall bypass
This commit is contained in:
parent
fc8fab1a03
commit
0a5981c657
2 changed files with 8 additions and 7 deletions
|
@ -23,9 +23,8 @@ import (
|
|||
var (
|
||||
dataRoot *utils.DirStructure
|
||||
|
||||
apiAddressSet bool
|
||||
apiIP net.IP
|
||||
apiPort uint16
|
||||
apiPortSet bool
|
||||
apiPort uint16
|
||||
)
|
||||
|
||||
func prepAPIAuth() error {
|
||||
|
@ -35,11 +34,13 @@ func prepAPIAuth() error {
|
|||
|
||||
func startAPIAuth() {
|
||||
var err error
|
||||
apiIP, apiPort, err = parseHostPort(apiListenAddress())
|
||||
_, apiPort, err = parseHostPort(apiListenAddress())
|
||||
if err != nil {
|
||||
log.Warningf("firewall: failed to parse API address for improved api auth mechanism: %s", err)
|
||||
return
|
||||
}
|
||||
apiAddressSet = true
|
||||
apiPortSet = true
|
||||
log.Tracef("firewall: api port set to %d", apiPort)
|
||||
}
|
||||
|
||||
func apiAuthenticator(s *http.Server, r *http.Request) (grantAccess bool, err error) {
|
||||
|
|
|
@ -111,8 +111,8 @@ func handlePacket(pkt packet.Packet) {
|
|||
}
|
||||
|
||||
// allow api access, if address was parsed successfully
|
||||
if apiAddressSet {
|
||||
if (pkt.Info().DstPort == apiPort && pkt.Info().Dst.Equal(apiIP)) || (pkt.Info().SrcPort == apiPort && pkt.Info().Src.Equal(apiIP)) {
|
||||
if apiPortSet {
|
||||
if (pkt.Info().DstPort == apiPort || pkt.Info().SrcPort == apiPort) && pkt.Info().Src.Equal(pkt.Info().Dst) {
|
||||
log.Debugf("accepting api connection: %s", pkt)
|
||||
pkt.PermanentAccept()
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue