Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
7c5e78b
Update app profile icons. Switch to new portbase options
ppacher Sep 7, 2020
7f8a557
Update to portbase/notification changes
ppacher Sep 15, 2020
ae67bb5
Merge pull request #143 from safing/fix/options
ppacher Sep 16, 2020
52c4cfe
Merge pull request #145 from safing/fix/notifications
ppacher Sep 16, 2020
a5e3f7f
Refactor status package to use portbase/runtime.
ppacher Sep 21, 2020
c125262
Add category annotations to options
ppacher Sep 22, 2020
4733fcb
Merge pull request #153 from safing/feature/option-categories
ppacher Sep 22, 2020
51c4835
Merge pull request #152 from safing/feature/status-n-notifs
ppacher Sep 22, 2020
69962fc
Merge branch 'develop' into feature/ui-revamp
ppacher Sep 29, 2020
da194c3
Register runtime provider at module startup
ppacher Sep 30, 2020
fb930d7
Reword the update notification and endpoint rule reason
ppacher Oct 5, 2020
f496330
Fix incorrect usage of PushUpdate in process package
ppacher Oct 7, 2020
67f0a98
Fix incorrect usage of PushFunc in status package
ppacher Oct 7, 2020
75bc5df
Refactor connection locking
ppacher Oct 7, 2020
67b3d76
Merge pull request #170 from safing/fix/race-conditions
ppacher Oct 8, 2020
5d901f5
Merge pull request #169 from safing/feature/update-notif-wording
ppacher Oct 8, 2020
4fc5c65
Add ProcessContext to network connection
ppacher Oct 8, 2020
ea1c91b
Return mitigation level normal instead of off for no threads
ppacher Oct 8, 2020
7feefc1
Merge pull request #171 from safing/feature/conn-proc-ctx
ppacher Oct 8, 2020
da09255
Merge pull request #172 from safing/fix/auto-pilot-level
ppacher Oct 8, 2020
f65d3f3
Merge branch 'develop' into feature/ui-revamp
ppacher Oct 15, 2020
2ccf8c6
Merge branch 'develop' into feature/ui-revamp
ppacher Oct 16, 2020
997787e
Merge branch 'develop' into feature/ui-revamp
ppacher Oct 20, 2020
9ea2162
Add quick setting support
ppacher Oct 27, 2020
a26b72c
Merge pull request #182 from safing/feature/quick-settings
dhaavi Oct 28, 2020
263eb05
Improve config wording
dhaavi Oct 29, 2020
c09d32c
Add option key responsible for the verdict
dhaavi Oct 29, 2020
18a1386
Revamp profile and process handling
dhaavi Oct 29, 2020
b7f0b85
Fix and improve prompting
dhaavi Oct 29, 2020
f71ee66
Update upgrader notification action to recent update
dhaavi Oct 29, 2020
17a0c8f
Fix Windows notifications
dhaavi Oct 29, 2020
ed00e1f
Add titles and categories to notifications
dhaavi Oct 29, 2020
fa3f873
Implement review feedback
dhaavi Oct 30, 2020
7b72d9f
Clean up code and fix linter errors
dhaavi Oct 30, 2020
49c3f54
Merge pull request #183 from safing/feature/ui-revamp-ingest
ppacher Oct 30, 2020
c050904
Add stackable annotation to endpoint rules
ppacher Oct 30, 2020
fb6b34e
Fix layered profiles not readable via the API
ppacher Oct 30, 2020
079128f
Fix layered profiles not readable via the API
ppacher Oct 30, 2020
607d77a
Add support for database subscription to layered profile provider
ppacher Oct 30, 2020
276a383
Merge pull request #184 from safing/fix/profile-runtime
dhaavi Nov 2, 2020
f5bde3a
Fix incorrect layered profile key
ppacher Nov 2, 2020
5339e8b
Merge pull request #185 from safing/fix/profiles
dhaavi Nov 2, 2020
d4dea21
Fix decoding IPv6 addresses
dhaavi Nov 2, 2020
9144188
Add IPv6 dual-stack support
dhaavi Nov 2, 2020
e0eb872
Merge pull request #186 from safing/feature/ipv6-dual-stack-support
ppacher Nov 4, 2020
a0268ee
Update config wording and metadata
dhaavi Nov 4, 2020
30f84e8
Improve missing dns servers module error
dhaavi Nov 4, 2020
385c0a1
Revamp automatic updates setting and adapt its usage
dhaavi Nov 4, 2020
24d2134
Merge pull request #187 from safing/feature/config-wording-update
ppacher Nov 4, 2020
057d167
Block DNS requests with IPs 0.0.0.17 and ::17
dhaavi Nov 4, 2020
d5e2520
Move connectivity domain decider
dhaavi Nov 4, 2020
7ca61bf
Block DNS servers in prevent bypassing check
dhaavi Oct 29, 2020
2400a3b
Merge pull request #188 from safing/feature/block-dns-servers-in-bypa…
ppacher Nov 5, 2020
a7df109
Merge pull request #189 from safing/feature/improve-firewall-blocking
ppacher Nov 5, 2020
b018786
Improve prompt notifications
dhaavi Nov 5, 2020
6a4dd03
Merge pull request #191 from safing/feature/improve-prompt-notifications
ppacher Nov 5, 2020
c541654
Fix exposing the wrong profile name on the connection process context
ppacher Nov 5, 2020
224ae21
Merge pull request #190 from safing/fix/profile-name
dhaavi Nov 5, 2020
28bb8ec
Fix connection blocking on Linux
dhaavi Nov 6, 2020
d5c00e3
Merge pull request #192 from safing/fix/nfqueue-and-packet-blocking
ppacher Nov 6, 2020
563bff1
Update filterlists to use new format
dhaavi Nov 6, 2020
54daa8b
Retry saving the global config profile when it fails
dhaavi Nov 6, 2020
9a240a2
Merge pull request #193 from safing/fix/filterlist-parsing
ppacher Nov 6, 2020
e74ca57
Improve Rules and Filter Lists help texts
dhaavi Nov 9, 2020
4840127
Adapt profiles to use new binary metadata system
dhaavi Nov 17, 2020
8b60a6b
Implement review suggestions
dhaavi Nov 17, 2020
4b694c5
Merge pull request #195 from safing/feature/profile-metadata
ppacher Nov 17, 2020
d7a3d65
Implement review suggestion
dhaavi Nov 24, 2020
e719b74
Merge pull request #194 from safing/feature/improve-rules-and-filterl…
dhaavi Nov 24, 2020
5a88fc2
Improve metadata handling of profiles
dhaavi Nov 24, 2020
f21c169
Add support for unpacking resources
dhaavi Nov 24, 2020
6c9d853
Add support for staging and purging
dhaavi Nov 24, 2020
0ac67a0
Fix log location for core on windows
dhaavi Nov 24, 2020
a98673c
Add support for redir-404-to-index type apps
dhaavi Nov 24, 2020
8b04580
Update pack scripts
dhaavi Nov 24, 2020
3e29a7d
Merge pull request #198 from safing/feature/profile-metadata-and-spec…
dhaavi Nov 24, 2020
b6fd649
Merge pull request #199 from safing/feature/improve-updates-and-relea…
dhaavi Nov 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 33 additions & 21 deletions cmds/portmaster-core/pack
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
baseDir="$( cd "$(dirname "$0")" && pwd )"
cd "$baseDir"

COL_OFF="\033[00m"
COL_OFF="\033[0m"
COL_BOLD="\033[01;01m"
COL_RED="\033[31m"
COL_GREEN="\033[32m"
COL_YELLOW="\033[33m"

destDirPart1="../../dist"
destDirPart2="core"

function check {
function prep {
# output
output="main"
# get version
Expand All @@ -25,46 +27,47 @@ function check {
fi
# build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
}

function check {
prep

# check if file exists
if [[ -f $destPath ]]; then
echo "[core] $platform $version already built"
echo "[core] $platform v$version already built"
else
echo -e "${COL_BOLD}[core] $platform $version${COL_OFF}"
echo -e "${COL_BOLD}[core] $platform v$version${COL_OFF}"
fi
}

function build {
# output
output="main"
# get version
version=$(grep "info.Set" main.go | cut -d'"' -f4)
# build versioned file name
filename="portmaster-core_v${version//./-}"
# platform
platform="${GOOS}_${GOARCH}"
if [[ $GOOS == "windows" ]]; then
filename="${filename}.exe"
output="${output}.exe"
fi
# build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
prep

# check if file exists
if [[ -f $destPath ]]; then
echo "[core] $platform already built in version $version, skipping..."
echo "[core] $platform already built in v$version, skipping..."
return
fi

# build
./build main.go
if [[ $? -ne 0 ]]; then
echo -e "\n${COL_BOLD}[core] $platform: ${COL_RED}BUILD FAILED.${COL_OFF}"
echo -e "\n${COL_BOLD}[core] $platform v$version: ${COL_RED}BUILD FAILED.${COL_OFF}"
exit 1
fi
mkdir -p $(dirname $destPath)
cp $output $destPath
echo -e "\n${COL_BOLD}[core] $platform: successfully built.${COL_OFF}"
echo -e "\n${COL_BOLD}[core] $platform v$version: ${COL_GREEN}successfully built.${COL_OFF}"
}

function reset {
prep

# delete if file exists
if [[ -f $destPath ]]; then
rm $destPath
echo "[core] $platform v$version deleted."
fi
}

function check_all {
Expand All @@ -79,13 +82,22 @@ function build_all {
GOOS=darwin GOARCH=amd64 build
}

function reset_all {
GOOS=linux GOARCH=amd64 reset
GOOS=windows GOARCH=amd64 reset
GOOS=darwin GOARCH=amd64 reset
}

case $1 in
"check" )
check_all
;;
"build" )
build_all
;;
"reset" )
reset_all
;;
* )
echo ""
echo "build list:"
Expand Down
48 changes: 36 additions & 12 deletions cmds/portmaster-start/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

var (
dataDir string
staging bool
maxRetries int
dataRoot *utils.DirStructure
logsRoot *utils.DirStructure
Expand All @@ -41,8 +42,8 @@ var (
Use: "portmaster-start",
Short: "Start Portmaster components",
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
mustLoadIndex := cmd == updatesCmd
if err := configureDataRoot(mustLoadIndex); err != nil {
mustLoadIndex := indexRequired(cmd)
if err := configureRegistry(mustLoadIndex); err != nil {
return err
}

Expand All @@ -64,8 +65,9 @@ func init() {
{
flags.StringVar(&dataDir, "data", "", "Configures the data directory. Alternatively, this can also be set via the environment variable PORTMASTER_DATA.")
flags.StringVar(&registry.UserAgent, "update-agent", "Start", "Sets the user agent for requests to the update server")
flags.BoolVar(&staging, "staging", false, "Use staging update channel (for testing only)")
flags.IntVar(&maxRetries, "max-retries", 5, "Maximum number of retries when starting a Portmaster component")
flags.BoolVar(&stdinSignals, "input-signals", false, "Emulate signals using stdid.")
flags.BoolVar(&stdinSignals, "input-signals", false, "Emulate signals using stdin.")
_ = rootCmd.MarkPersistentFlagDirname("data")
_ = flags.MarkHidden("input-signals")
}
Expand Down Expand Up @@ -131,34 +133,32 @@ func initCobra() {
portlog.SetLogLevel(portlog.CriticalLevel)
}

func configureDataRoot(mustLoadIndex bool) error {
// The data directory is not
// check for environment variable
// PORTMASTER_DATA
func configureRegistry(mustLoadIndex bool) error {
// If dataDir is not set, check the environment variable.
if dataDir == "" {
dataDir = os.Getenv("PORTMASTER_DATA")
}

// if it's still empty try to auto-detect it
// If it's still empty, try to auto-detect it.
if dataDir == "" {
dataDir = detectInstallationDir()
}

// finally, if it's still empty the user must provide it
// Finally, if it's still empty, the user must provide it.
if dataDir == "" {
return errors.New("please set the data directory using --data=/path/to/data/dir")
}

// remove redundant escape characters and quotes
// Remove left over quotes.
dataDir = strings.Trim(dataDir, `\"`)
// initialize dataroot
// Initialize data root.
err := dataroot.Initialize(dataDir, 0755)
if err != nil {
return fmt.Errorf("failed to initialize data root: %s", err)
}
dataRoot = dataroot.Root()

// initialize registry
// Initialize registry.
err = registry.Initialize(dataRoot.ChildDir("updates", 0755))
if err != nil {
return err
Expand All @@ -177,6 +177,19 @@ func configureDataRoot(mustLoadIndex bool) error {
// Beta: true,
// })

if stagingActive() {
// Set flag no matter how staging was activated.
staging = true

log.Println("WARNING: staging environment is active.")

registry.AddIndex(updater.Index{
Path: "staging.json",
Stable: true,
Beta: true,
})
}

return updateRegistryIndex(mustLoadIndex)
}

Expand Down Expand Up @@ -233,3 +246,14 @@ func detectInstallationDir() string {

return parent
}

func stagingActive() bool {
// Check flag and env variable.
if staging || os.Getenv("PORTMASTER_STAGING") == "enabled" {
return true
}

// Check if staging index is present and acessible.
_, err := os.Stat(filepath.Join(registry.StorageDir().Path, "staging.json"))
return err == nil
}
52 changes: 32 additions & 20 deletions cmds/portmaster-start/pack
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
baseDir="$( cd "$(dirname "$0")" && pwd )"
cd "$baseDir"

COL_OFF="\033[00m"
COL_OFF="\033[0m"
COL_BOLD="\033[01;01m"
COL_RED="\033[31m"
COL_GREEN="\033[32m"
COL_YELLOW="\033[33m"

destDirPart1="../../dist"
destDirPart2="start"

function check {
function prep {
# output
output="portmaster-start"
# get version
Expand All @@ -25,46 +27,47 @@ function check {
fi
# build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
}

function check {
prep

# check if file exists
if [[ -f $destPath ]]; then
echo "[start] $platform $version already built"
else
echo -e "${COL_BOLD}[start] $platform $version${COL_OFF}"
echo -e "${COL_BOLD}[start] $platform v$version${COL_OFF}"
fi
}

function build {
# output
output="portmaster-start"
# get version
version=$(grep "info.Set" main.go | cut -d'"' -f4)
# build versioned file name
filename="portmaster-start_v${version//./-}"
# platform
platform="${GOOS}_${GOARCH}"
if [[ $GOOS == "windows" ]]; then
filename="${filename}.exe"
output="${output}.exe"
fi
# build destination path
destPath=${destDirPart1}/${platform}/${destDirPart2}/$filename
prep

# check if file exists
if [[ -f $destPath ]]; then
echo "[start] $platform already built in version $version, skipping..."
echo "[start] $platform already built in v$version, skipping..."
return
fi

# build
./build
if [[ $? -ne 0 ]]; then
echo -e "\n${COL_BOLD}[start] $platform: ${COL_RED}BUILD FAILED.${COL_OFF}"
echo -e "\n${COL_BOLD}[start] $platform v$version: ${COL_RED}BUILD FAILED.${COL_OFF}"
exit 1
fi
mkdir -p $(dirname $destPath)
cp $output $destPath
echo -e "\n${COL_BOLD}[start] $platform: successfully built.${COL_OFF}"
echo -e "\n${COL_BOLD}[start] $platform v$version: ${COL_GREEN}successfully built.${COL_OFF}"
}

function reset {
prep

# delete if file exists
if [[ -f $destPath ]]; then
rm $destPath
echo "[start] $platform v$version deleted."
fi
}

function check_all {
Expand All @@ -79,13 +82,22 @@ function build_all {
GOOS=darwin GOARCH=amd64 build
}

function reset_all {
GOOS=linux GOARCH=amd64 reset
GOOS=windows GOARCH=amd64 reset
GOOS=darwin GOARCH=amd64 reset
}

case $1 in
"check" )
check_all
;;
"build" )
build_all
;;
"reset" )
reset_all
;;
* )
echo ""
echo "build list:"
Expand Down
Loading