Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ jobs:
go-version: ^1.18
- uses: actions/checkout@v3
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v9
# See https://github.com/golangci/golangci-lint-action/issues/485 for why we do --out-....
with:
version: latest
args: "-E stylecheck,revive,gocritic --out-${NO_FUTURE}format colored-line-number --timeout 5m"
args: "-E staticcheck,revive,gocritic --timeout 5m"

build-cli:
name: Build CLI
Expand Down Expand Up @@ -69,4 +69,4 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: ^1.18
- run: make test
- run: make test
18 changes: 9 additions & 9 deletions cmd/geteduroam-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import (
"golang.org/x/sys/unix"
"golang.org/x/term"

"github.com/geteduroam/linux-app/internal/clientver"
"github.com/geteduroam/linux-app/internal/discovery"
"github.com/geteduroam/linux-app/internal/handler"
"github.com/geteduroam/linux-app/internal/log"
"github.com/geteduroam/linux-app/internal/logwrap"
"github.com/geteduroam/linux-app/internal/network"
"github.com/geteduroam/linux-app/internal/notification"
"github.com/geteduroam/linux-app/internal/provider"
"github.com/geteduroam/linux-app/internal/utils"
"github.com/geteduroam/linux-app/internal/utilsx"
"github.com/geteduroam/linux-app/internal/variant"
"github.com/geteduroam/linux-app/internal/version"
)

// IsTerminal return true if the file descriptor is terminal.
Expand Down Expand Up @@ -445,7 +445,7 @@ func main() {
var local string
var url string
program := fmt.Sprintf("%s-cli", variant.DisplayName)
lpath, err := log.Location(program)
lpath, err := logwrap.Location(program)
if err != nil {
lpath = "N/A"
}
Expand All @@ -466,11 +466,11 @@ func main() {
return
}
if verbose {
utils.IsVerbose = true
utilsx.IsVerbose = true
}
log.Initialize(program, debug)
logwrap.Initialize(program, debug)
if versionf {
fmt.Println(version.Get())
fmt.Println(clientver.Get())
return
}
if !IsTerminal() {
Expand Down Expand Up @@ -503,13 +503,13 @@ func main() {
if vEnd == nil {
return
}
fmt.Printf("Your profile is valid for: %d days\n", utils.ValidityDays(*vEnd))
fmt.Printf("Your profile is valid for: %d days\n", utilsx.ValidityDays(*vEnd))
curr := time.Now()
if vBeg != nil && curr.Before(*vBeg) {
delta := vBeg.Sub(curr)
// if there is more than 5 second difference we show a countdown
if delta > 5*time.Second {
fmt.Printf("And you can start using the profile in: %s\n", utils.DeltaTime(delta, "", ""))
fmt.Printf("And you can start using the profile in: %s\n", utilsx.DeltaTime(delta, "", ""))
}
}
if !notification.HasDaemonSupport() {
Expand Down
14 changes: 7 additions & 7 deletions cmd/geteduroam-gui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"github.com/jwijenbergh/puregotk/v4/glib"
"github.com/jwijenbergh/puregotk/v4/gtk"

"github.com/geteduroam/linux-app/internal/clientver"
"github.com/geteduroam/linux-app/internal/discovery"
"github.com/geteduroam/linux-app/internal/handler"
"github.com/geteduroam/linux-app/internal/log"
"github.com/geteduroam/linux-app/internal/logwrap"
"github.com/geteduroam/linux-app/internal/network"
"github.com/geteduroam/linux-app/internal/provider"
"github.com/geteduroam/linux-app/internal/variant"
"github.com/geteduroam/linux-app/internal/version"
)

type serverList struct {
Expand Down Expand Up @@ -364,14 +364,14 @@ func (m *mainState) initBurger() {
awin.SetLogo(texture)
defer texture.Unref()
}
lpath, err := log.Location(fmt.Sprintf("%s-gui", variant.DisplayName))
lpath, err := logwrap.Location(fmt.Sprintf("%s-gui", variant.DisplayName))
if err == nil {
awin.SetSystemInformation("Log location: " + lpath)
}
awin.SetProgramName(fmt.Sprintf("%s GUI", variant.DisplayName))
awin.SetComments(fmt.Sprintf("Client to easily and securely configure %s", variant.ProfileName))
awin.SetAuthors([]string{"Jeroen Wijenbergh", "Martin van Es", "Alexandru Cacean"})
awin.SetVersion(version.Get())
awin.SetVersion(clientver.Get())
awin.SetWebsite("https://github.com/geteduroam/linux-app")
// SetLicenseType has a scary warning: "comes with absolutely no warranty"
// While it is true according to the license, I find it unfriendly
Expand Down Expand Up @@ -478,7 +478,7 @@ func main() {
var debug bool
var gtkarg string
program := fmt.Sprintf("%s-gui", variant.DisplayName)
lpath, err := log.Location(program)
lpath, err := logwrap.Location(program)
if err != nil {
lpath = "N/A"
}
Expand All @@ -496,7 +496,7 @@ func main() {
}

if versionf {
fmt.Println(version.Get())
fmt.Println(clientver.Get())
return
}

Expand Down Expand Up @@ -528,7 +528,7 @@ func main() {

glib.LogSetDefaultHandler(&handler, 0)

log.Initialize(program, debug)
logwrap.Initialize(program, debug)
ui := ui{}
args := []string{os.Args[0]}
if gtkarg != "" {
Expand Down
8 changes: 4 additions & 4 deletions cmd/geteduroam-gui/success.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/geteduroam/linux-app/internal/notification"
"github.com/geteduroam/linux-app/internal/utils"
"github.com/geteduroam/linux-app/internal/utilsx"
"github.com/geteduroam/linux-app/internal/variant"
"github.com/jwijenbergh/puregotk/v4/adw"
"github.com/jwijenbergh/puregotk/v4/glib"
Expand Down Expand Up @@ -74,12 +74,12 @@ func (s *SuccessState) Initialize() {
delta := time.Until(*s.vBeg)
// We do not want to show on 0 seconds
if delta >= 1*time.Second {
valid.SetMarkup(fmt.Sprintf("Your profile will be valid in: %s", utils.DeltaTime(delta, "<b>", "</b>")))
valid.SetMarkup(fmt.Sprintf("Your profile will be valid in: %s", utilsx.DeltaTime(delta, "<b>", "</b>")))
valid.Show()
return true
}
if s.vEnd != nil {
valid.SetMarkup(fmt.Sprintf("%s <b>%d</b> days", validText, utils.ValidityDays(*s.vEnd)))
valid.SetMarkup(fmt.Sprintf("%s <b>%d</b> days", validText, utilsx.ValidityDays(*s.vEnd)))
} else { // not very realistic this happens, but in theory it could
valid.SetMarkup("Your profile is valid")
}
Expand All @@ -99,7 +99,7 @@ func (s *SuccessState) Initialize() {
return
}

dialog := gtk.NewMessageDialog(s.parent, gtk.DialogDestroyWithParentValue, gtk.MessageQuestionValue, gtk.ButtonsYesNoValue, "This connection profile will expire in %i days.\n\nDo you want to enable notifications that warn for imminent expiry using systemd?", utils.ValidityDays(*s.vEnd))
dialog := gtk.NewMessageDialog(s.parent, gtk.DialogDestroyWithParentValue, gtk.MessageQuestionValue, gtk.ButtonsYesNoValue, "This connection profile will expire in %i days.\n\nDo you want to enable notifications that warn for imminent expiry using systemd?", utilsx.ValidityDays(*s.vEnd))
dialog.Present()
var dialogcb func(gtk.Dialog, int)
dialogcb = func(_ gtk.Dialog, response int) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/geteduroam-gui/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func bytesPixbuf(b []byte) (*gdkpixbuf.Pixbuf, error) {
if err != nil {
return nil, err
}
defer os.Remove(f.Name())
defer os.Remove(f.Name()) //nolint:errcheck
_, err = f.Write(b)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions cmd/geteduroam-notifcheck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"golang.org/x/exp/slog"

"github.com/geteduroam/linux-app/internal/config"
"github.com/geteduroam/linux-app/internal/log"
"github.com/geteduroam/linux-app/internal/logwrap"
"github.com/geteduroam/linux-app/internal/nm"
"github.com/geteduroam/linux-app/internal/notification"
"github.com/geteduroam/linux-app/internal/variant"
Expand Down Expand Up @@ -43,13 +43,13 @@ func hasValidProfile(uuids []string) bool {

func main() {
program := fmt.Sprintf("%s-notifcheck", variant.DisplayName)
lpath, err := log.Location(program)
lpath, err := logwrap.Location(program)
if err != nil {
lpath = "N/A"
}
flag.Usage = func() { fmt.Printf(usage, program, variant.DisplayName, lpath) }
flag.Parse()
log.Initialize(fmt.Sprintf("%s-notifcheck", variant.DisplayName), false)
logwrap.Initialize(fmt.Sprintf("%s-notifcheck", variant.DisplayName), false)
cfg, err := config.Load()
if err != nil {
slog.Error("no previous state", "error", err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package version
// Package clientver implements version info for the client
package clientver

import (
"fmt"
Expand Down
8 changes: 4 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// package config has methods to write (TODO: read) config files
// Package config has methods to write (TODO: read) config files
package config

import (
Expand All @@ -9,7 +9,7 @@ import (

"golang.org/x/exp/slog"

"github.com/geteduroam/linux-app/internal/utils"
"github.com/geteduroam/linux-app/internal/utilsx"
"github.com/geteduroam/linux-app/internal/variant"
)

Expand Down Expand Up @@ -50,7 +50,7 @@ func Directory() (p string, err error) {
return
}

// Write writes the configuration to the filesystem with the filename and string
// WriteFile writes the configuration to the filesystem with the filename and string
func WriteFile(filename string, content []byte) (string, error) {
dir, err := Directory()
if err != nil {
Expand Down Expand Up @@ -90,7 +90,7 @@ func Load() (*Config, error) {
slog.Debug("Error reading config file", "file", p, "error", err)
return nil, err
}
utils.Verbosef("Reading config file %s", p)
utilsx.Verbosef("Reading config file %s", p)
// If a v1 config is found, migrate it to a v2 one if that is empty
hasV1 := v.ConfigV1 != nil && v.ConfigV1.UUID != ""
hasV2 := v.Config != nil && len(v.Config.UUIDs) > 0
Expand Down
4 changes: 2 additions & 2 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"reflect"
"testing"

"github.com/geteduroam/linux-app/internal/utils"
"github.com/geteduroam/linux-app/internal/utilsx"
)

func mockDir(t *testing.T, dir string) {
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestLoad(t *testing.T) {
// mock the config name
configName = curr.filename
gotc, goterr := Load()
if utils.ErrorString(goterr) != curr.wanterr {
if utilsx.ErrorString(goterr) != curr.wanterr {
t.Fatalf("expected config error not equal to want, got: %v, want: %v", goterr, curr.wanterr)
}
// to compare structs we can use deepequal
Expand Down
5 changes: 3 additions & 2 deletions internal/discovery/discovery.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// package discovery contains methods to parse the discovery format from https://discovery.eduroam.app/v3/discovery.json into providers
// Package discovery contains methods to parse the discovery format from https://discovery.eduroam.app/v3/discovery.json into providers
package discovery

import (
Expand All @@ -19,6 +19,7 @@ type Discovery struct {
Value Value `json:"http://letswifi.app/discovery#v3"`
}

// Value is the discovery JSON value
type Value struct {
Providers provider.Providers `json:"providers"`
// See: https://github.com/geteduroam/windows-app/blob/22cd90f36031907c7174fbdc678edafaa627ce49/CHANGELOG.md#changed
Expand Down Expand Up @@ -68,7 +69,7 @@ func (c *Cache) Providers() (*provider.Providers, error) {
slog.Debug("Error requesting discovery.json", "error", err)
return &c.Cached.Value.Providers, err
}
defer res.Body.Close()
defer res.Body.Close() //nolint:errcheck

body, err := io.ReadAll(res.Body)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/eap/eap.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// package eap implements an XML eap-config parser compliant with the XML schema found at https://github.com/GEANT/CAT/blob/master/devices/eap_config/eap-metadata.xsd
// Package eap implements an XML eap-config parser compliant with the XML schema found at https://github.com/GEANT/CAT/blob/master/devices/eap_config/eap-metadata.xsd
// A part of this was generated with xgen https://github.com/xuri/xgen
// By hand modified:
// - Use NonEAPAuthNumbers as alias instead of hardcoded int
Expand Down Expand Up @@ -338,8 +338,8 @@ func (ca *CertData) isValid(format string) bool {
return true
}

// CaList gets a list of certificates by looping through the certificate list and returning all *valid* certificates
func (ss *ServerCredentialVariants) CAList() ([]byte, error) {
// CAList gets a list of certificates by looping through the certificate list and returning all *valid* certificates
func (ss *ServerCredentialVariants) CAList() (cert.Certificates, error) {
var certs []string
for _, c := range ss.CA {
if c.isValid("X.509") {
Expand Down
10 changes: 5 additions & 5 deletions internal/eap/eap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/geteduroam/linux-app/internal/network/cert"
"github.com/geteduroam/linux-app/internal/network/inner"
"github.com/geteduroam/linux-app/internal/network/method"
"github.com/geteduroam/linux-app/internal/utils"
"github.com/geteduroam/linux-app/internal/utilsx"
)

type authMethodTest struct {
Expand All @@ -30,7 +30,7 @@ func testAuthMethod(t *testing.T, eip *EAPIdentityProvider, cases []authMethodTe
if r != c.want {
t.Fatalf("method is not what is expected, got: %d, want: %d", r, c.want)
}
if utils.ErrorString(err) != c.err {
if utilsx.ErrorString(err) != c.err {
t.Fatalf("error is not expected, got: %v, want: %v", err, c.err)
}
}
Expand All @@ -53,7 +53,7 @@ func testSSIDSettings(t *testing.T, eip *EAPIdentityProvider, settings ssidSetti
if !reflect.DeepEqual(gotSSIDs, settings.SSIDs) {
t.Fatalf("SSIDs is not equal, got: %v, want: %v", gotSSIDs, settings.SSIDs)
}
gotErrS := utils.ErrorString(gotErr)
gotErrS := utilsx.ErrorString(gotErr)
if gotErrS != settings.err {
t.Fatalf("Error for SSID settings is not equal, got: %v, want: %v", gotErrS, settings.err)
}
Expand All @@ -72,7 +72,7 @@ type parseTest struct {
netTest networkTest
}

func mustParseCert(t *testing.T, root string) []byte {
func mustParseCert(t *testing.T, root string) cert.Certificates {
c, err := cert.New([]string{root})
if err != nil {
t.Fatalf("failed to generate certs: %v", err)
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestParse(t *testing.T) {

// finally test the whole network we get back
n, err := eipl.Network()
errS := utils.ErrorString(err)
errS := utilsx.ErrorString(err)
if errS != c.netTest.err {
t.Fatalf("network error not equal. Got: %v, want: %v", errS, c.netTest.err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/handler/handler.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// package handlers handles the eduroam connection by parsing the byte array
// Package handler handles the eduroam connection by parsing the byte array
// It has handlers for UI events
package handler

Expand Down
Loading