Skip to content

Commit 7cd8005

Browse files
author
Safing
committed
Merge branch 'develop' into feature/inspection-framework
2 parents 19bb417 + f1e587f commit 7cd8005

File tree

23 files changed

+349
-109
lines changed

23 files changed

+349
-109
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Think of a pi-hole for your computer. Or an ad-blocker that blocks ads on your w
3535
**Features/Settings:**
3636

3737
- Select and activate block-lists
38-
- Manually black/whitelist domains
39-
- You can whitelist domains in case something breaks
38+
- Manually block/allow domains
39+
- You can allow domains in case something breaks
4040
- CNAME Blocking (block these new nasty "unblockable" ads/trackers)
4141
- Block all subdomains of a domain in the block-lists
4242

cmds/portmaster-core/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
func main() {
2121
// set information
22-
info.Set("Portmaster", "0.5.0", "AGPLv3", true)
22+
info.Set("Portmaster", "0.5.2", "AGPLv3", true)
2323

2424
// enable SPN client mode
2525
conf.EnableClient(true)

cmds/portmaster-start/install_windows.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import (
1919
"golang.org/x/sys/windows/svc/mgr"
2020
)
2121

22-
const exeSuffix = ".exe"
23-
2422
func init() {
2523
rootCmd.AddCommand(installCmd)
2624
installCmd.AddCommand(installService)

cmds/portmaster-start/recover_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var recoverIPTablesCmd = &cobra.Command{
4848

4949
if filteredErrors != nil {
5050
filteredErrors.ErrorFormat = formatNfqErrors
51-
return filteredErrors
51+
return filteredErrors.ErrorOrNil()
5252
}
5353

5454
return nil

cmds/portmaster-start/service_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ service:
8888
return ssec, errno
8989
}
9090

91-
func runService(cmd *cobra.Command, opts *Options, cmdArgs []string) error {
91+
func runService(_ *cobra.Command, opts *Options, cmdArgs []string) error {
9292
// check if we are running interactively
9393
isDebug, err := svc.IsAnInteractiveSession()
9494
if err != nil {

core/events.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55

66
"github.com/safing/portbase/log"
77
"github.com/safing/portbase/modules"
8+
"github.com/safing/portmaster/updates"
89
)
910

1011
const (
1112
eventShutdown = "shutdown"
1213
eventRestart = "restart"
13-
restartCode = 23
1414
)
1515

1616
func registerEvents() {
@@ -43,8 +43,6 @@ func shutdown(ctx context.Context, _ interface{}) error {
4343
// restart restarts the Portmaster.
4444
func restart(ctx context.Context, data interface{}) error {
4545
log.Info("core: user requested restart")
46-
modules.SetExitStatusCode(restartCode)
47-
// Do not use a worker, as this would block itself here.
48-
go modules.Shutdown() //nolint:errcheck
46+
updates.RestartNow()
4947
return nil
5048
}

detection/dga/lms.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ import (
44
"strings"
55
)
66

7-
// LmsScoreOfDomain calculates the mean longest meaningful substring of a domain. It follows some special rules to increase accuracy. It returns a value between 0 and 100, representing the length-based percentage of the meaningful substring.
7+
// LmsScoreOfDomain calculates the mean longest meaningful substring of a domain.
8+
// It follows some special rules to increase accuracy. It returns a value between
9+
// 0 and 100, representing the length-based percentage of the meaningful substring.
810
func LmsScoreOfDomain(domain string) float64 {
911
var totalScore float64
1012
domain = strings.ToLower(domain)
1113
subjects := strings.Split(domain, ".")
12-
// ignore the last two parts
13-
if len(subjects) <= 3 {
14-
return 100
15-
}
16-
subjects = subjects[:len(subjects)-3]
1714
var totalLength int
1815
for _, subject := range subjects {
1916
totalLength += len(subject)
@@ -27,7 +24,9 @@ func LmsScoreOfDomain(domain string) float64 {
2724
return totalScore
2825
}
2926

30-
// LmsScore calculates the longest meaningful substring of a domain. It returns a value between 0 and 100, representing the length-based percentage of the meaningful substring.
27+
// LmsScore calculates the longest meaningful substring of a domain. It returns a
28+
// value between 0 and 100, representing the length-based percentage of the
29+
// meaningful substring.
3130
func LmsScore(subject string) float64 {
3231
lmsStart := -1
3332
lmsStop := -1

detection/dga/lms_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import "testing"
55
func TestLmsScoreOfDomain(t *testing.T) {
66
testDomain(t, "g.symcd.com.", 100, 100)
77
testDomain(t, "www.google.com.", 100, 100)
8-
testDomain(t, "55ttt5.12abc3.test.com.", 50, 50)
9-
testDomain(t, "mbtq6opnuodp34gcrma65fxacgxv5ukr7lq6xuhr4mhoibe7.yvqptrozfbnqyemchpovw3q5xwjibuxfsgb72mix3znhpfhc.i2n7jh2gadqaadck3zs3vg3hbv5pkmwzeay4gc75etyettbb.isi5mhmowtfriu33uxzmgvjur5g2p3tloynwohfrggee6fkn.meop7kqyd5gwxxa3.er.spotify.com.", 0, 30)
8+
testDomain(t, "55ttt5.12abc3.test.com.", 68, 69)
9+
testDomain(t, "mbtq6opnuodp34gcrma65fxacgxv5ukr7lq6xuhr4mhoibe7.yvqptrozfbnqyemchpovw3q5xwjibuxfsgb72mix3znhpfhc.i2n7jh2gadqaadck3zs3vg3hbv5pkmwzeay4gc75etyettbb.isi5mhmowtfriu33uxzmgvjur5g2p3tloynwohfrggee6fkn.meop7kqyd5gwxxa3.er.spotify.com.", 0, 31)
1010
}
1111

1212
func testDomain(t *testing.T, domain string, min, max float64) {

firewall/interception/nfqexp/nfqexp.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build linux
2+
13
// Package nfqexp contains a nfqueue library experiment.
24
package nfqexp
35

firewall/interception/nfqexp/packet.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build linux
2+
13
package nfqexp
24

35
import (

0 commit comments

Comments
 (0)