Skip to content

Commit

Permalink
Testing of issues 24, 8, 10 (#36)
Browse files Browse the repository at this point in the history
* issue 24 - update to support go version 1.18

* issue 8 - Remove requirement to "run as Administrator"

* fix merge issues, mod tidy, obsolete syntax removed

* fix build issues

* fix installer and build

* fix build

* fix workflow

* fix installer and workflow

* missed instructions in merge

* functional proxy fixes

* integrated listening address override from tray as service

* fix service configuration override

* fix service installation and installer
  • Loading branch information
parvit authored Jan 23, 2023
1 parent 032bab7 commit 4f163d0
Show file tree
Hide file tree
Showing 46 changed files with 1,768 additions and 1,198 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ on:
default: false
push:
branches: [ "main", "testing-*" ]
pull_request:
branches: [ "main" ]

jobs:
build-linux:
Expand Down Expand Up @@ -38,7 +36,7 @@ jobs:
go test -v ./...
continue-on-error: true

- name: Build x64
- name: Build 64bits
run: |
set GOARCH=amd64
set GOOS=linux
Expand Down Expand Up @@ -85,29 +83,29 @@ jobs:
- name: Prepare
run: |
MKDIR build
MKDIR build\x64
MKDIR build\x86
MKDIR build\64bits
MKDIR build\32bits
COPY /Y windivert\LICENSE build\LICENSE.windivert
COPY /Y LICENSE build\LICENSE
set GOARCH=amd64
go clean -cache
set GOARCH=386
go clean -cache
COPY /Y windivert\x64\* build\x64
COPY /Y windivert\x64\* build\64bits
- name: Build QPep x64
- name: Build QPep 64bits
run: |
set GOARCH=amd64
set CGO_ENABLED=1
go build -o build\x64\qpep.exe
go build -o build\64bits\qpep.exe
- name: Build QPep Tray x64
- name: Build QPep Tray 64bits
run: |
pushd qpep-tray
set GOARCH=amd64
set GOOS=windows
set CGO_ENABLED=0
go build -ldflags -H=windowsgui -o ..\build\x86\qpep-tray.exe
go build -ldflags -H=windowsgui -o ..\build\64bits\qpep-tray.exe
popd
- if: ${{ github.event.inputs.x86_version == true }}
Expand All @@ -122,7 +120,7 @@ jobs:
set GOARCH=386
set GOOS=windows
set CGO_ENABLED=1
go build -o build\x64\qpep.exe
go build -o build\64bits\qpep.exe
- if: ${{ github.event.inputs.x86_version == true }}
name: Build QPep Tray x86
Expand All @@ -131,7 +129,7 @@ jobs:
set GOARCH=386
set GOOS=windows
set CGO_ENABLED=0
go build -ldflags -H=windowsgui -o ..\build\x86\qpep-tray.exe
go build -ldflags -H=windowsgui -o ..\build\32bits\qpep-tray.exe
popd
- name: Build QPep Installer
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,29 @@ jobs:
- name: Prepare
run: |
MKDIR build
MKDIR build\x64
MKDIR build\x86
MKDIR build\64bits
MKDIR build\32bits
COPY /Y windivert\LICENSE build\LICENSE.windivert
COPY /Y LICENSE build\LICENSE
set GOARCH=amd64
go clean -cache
set GOARCH=386
go clean -cache
COPY /Y windivert\x64\* build\x64
COPY /Y windivert\x64\* build\64bits
- name: Build QPep x64
run: |
set GOARCH=amd64
set CGO_ENABLED=1
go build -o build\x64\qpep.exe
go build -o build\64bits\qpep.exe
- name: Build QPep Tray x64
run: |
pushd qpep-tray
set GOARCH=amd64
set GOOS=windows
set CGO_ENABLED=0
go build -ldflags -H=windowsgui -o ..\build\x86\qpep-tray.exe
go build -ldflags -H=windowsgui -o ..\build\32bits\qpep-tray.exe
popd
- if: ${{ github.event.inputs.x86_version == true }}
Expand All @@ -151,7 +151,7 @@ jobs:
set GOARCH=386
set GOOS=windows
set CGO_ENABLED=1
go build -o build\x64\qpep.exe
go build -o build\64bits\qpep.exe
- if: ${{ github.event.inputs.x86_version == true }}
name: Build QPep Tray x86
Expand All @@ -160,7 +160,7 @@ jobs:
set GOARCH=386
set GOOS=windows
set CGO_ENABLED=0
go build -ldflags -H=windowsgui -o ..\build\x86\qpep-tray.exe
go build -ldflags -H=windowsgui -o ..\build\32bits\qpep-tray.exe
popd
- name: Build QPep Installer
Expand Down
12 changes: 7 additions & 5 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import (
"time"

"github.com/julienschmidt/httprouter"

"github.com/parvit/qpep/shared"
"github.com/parvit/qpep/version"
)

func formatRequest(r *http.Request) string {
data, err := httputil.DumpRequest(r, shared.QuicConfiguration.Verbose)
data, err := httputil.DumpRequest(r, shared.QPepConfig.Verbose)
if err != nil {
return fmt.Sprintf("REQUEST: %v", err)
}
Expand Down Expand Up @@ -76,7 +78,7 @@ func apiEcho(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
data, err := json.Marshal(EchoResponse{
Address: dataAddr[0],
Port: port,
ServerVersion: shared.Version(),
ServerVersion: version.Version(),
})
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Expand All @@ -95,10 +97,10 @@ func apiVersions(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
server := "N/A"
client := "N/A"
if strings.Contains(r.URL.String(), API_PREFIX_SERVER) {
server = shared.Version()
server = version.Version()
} else {
server = Statistics.GetState(INFO_OTHER_VERSION)
client = shared.Version()
client = version.Version()
}

data, err := json.Marshal(VersionsResponse{
Expand Down Expand Up @@ -143,7 +145,7 @@ func apiStatisticsInfo(w http.ResponseWriter, r *http.Request, ps httprouter.Par
reqAddress := ps.ByName("addr")

lastUpdate := ""
address := shared.QuicConfiguration.ListenIP
address := shared.QPepConfig.ListenHost
platform := runtime.GOOS
if len(reqAddress) > 0 {
address = reqAddress
Expand Down
44 changes: 22 additions & 22 deletions api/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"bytes"
"encoding/json"
"fmt"
"log"
"net"
"net/http"
"net/url"
"runtime"
"strings"
"time"

. "github.com/parvit/qpep/logger"
"github.com/parvit/qpep/shared"
)

Expand All @@ -21,7 +21,7 @@ func getClientForAPI(localAddr net.Addr) *http.Client {
Timeout: 30 * time.Second,
Transport: &http.Transport{
Proxy: func(*http.Request) (*url.URL, error) {
log.Printf("API Proxy: %v %v\n", shared.UsingProxy, shared.ProxyAddress)
Info("API Proxy: %v %v\n", shared.UsingProxy, shared.ProxyAddress)
if shared.UsingProxy {
return shared.ProxyAddress, nil
}
Expand Down Expand Up @@ -50,30 +50,30 @@ func RequestEcho(localAddress, address string, port int, toServer bool) *EchoRes

resolvedAddr, errAddr := net.ResolveTCPAddr("tcp", localAddress+":0")
if errAddr != nil {
log.Printf("ERROR: %v\n", errAddr)
Info("ERROR: %v\n", errAddr)
return nil
}

clientInst := getClientForAPI(resolvedAddr)

req, err := http.NewRequest("GET", addr, nil)
if err != nil {
log.Printf("ERROR: %v\n", err)
Info("1 ERROR: %v\n", err)
return nil
}
req.Header.Set("User-Agent", runtime.GOOS)

resp, err := clientInst.Do(req)
if err != nil {
log.Printf("ERROR: %v\n", err)
Info("2 ERROR: %v\n", err)
return nil
}
defer func() {
_ = resp.Body.Close()
}()

if resp.StatusCode != http.StatusOK {
log.Printf("ERROR: BAD status code %d\n", resp.StatusCode)
Info("ERROR: BAD status code %d\n", resp.StatusCode)
return nil
}

Expand All @@ -84,18 +84,18 @@ func RequestEcho(localAddress, address string, port int, toServer bool) *EchoRes
}

if scanner.Err() != nil {
log.Printf("ERROR: %v\n", scanner.Err())
Info("3 ERROR: %v\n", scanner.Err())
return nil
}

if shared.QuicConfiguration.Verbose {
log.Printf("%s\n", str.String())
if shared.QPepConfig.Verbose {
Info("%s\n", str.String())
}

respData := &EchoResponse{}
jsonErr := json.Unmarshal(str.Bytes(), &respData)
if jsonErr != nil {
log.Printf("ERROR: %v\n", jsonErr)
Info("4 ERROR: %v\n", jsonErr)
return nil
}

Expand All @@ -117,15 +117,15 @@ func RequestStatus(localAddress, gatewayAddress string, apiPort int, publicAddre

resp, err := client.Get(addr)
if err != nil {
log.Printf("ERROR: %v\n", err)
Info("5 ERROR: %v\n", err)
return nil
}
defer func() {
_ = resp.Body.Close()
}()

if resp.StatusCode != http.StatusOK {
log.Printf("ERROR: BAD status code %d\n", resp.StatusCode)
Info("ERROR: BAD status code %d\n", resp.StatusCode)
return nil
}

Expand All @@ -136,18 +136,18 @@ func RequestStatus(localAddress, gatewayAddress string, apiPort int, publicAddre
}

if scanner.Err() != nil {
log.Printf("ERROR: %v\n", scanner.Err())
Info("6 ERROR: %v\n", scanner.Err())
return nil
}

if shared.QuicConfiguration.Verbose {
log.Printf("%s\n", str.String())
if shared.QPepConfig.Verbose {
Info("%s\n", str.String())
}

respData := &StatusReponse{}
jsonErr := json.Unmarshal(str.Bytes(), &respData)
if jsonErr != nil {
log.Printf("ERROR: %v\n", jsonErr)
Info("7 ERROR: %v\n", jsonErr)
return nil
}

Expand All @@ -164,15 +164,15 @@ func RequestStatistics(localAddress, gatewayAddress string, apiPort int, publicA

resp, err := clientInst.Get(addr)
if err != nil {
log.Printf("ERROR: %v\n", err)
Info("8 ERROR: %v\n", err)
return nil
}
defer func() {
_ = resp.Body.Close()
}()

if resp.StatusCode != http.StatusOK {
log.Printf("ERROR: BAD status code %d\n", resp.StatusCode)
Info("ERROR: BAD status code %d\n", resp.StatusCode)
return nil
}

Expand All @@ -183,18 +183,18 @@ func RequestStatistics(localAddress, gatewayAddress string, apiPort int, publicA
}

if scanner.Err() != nil {
log.Printf("ERROR: %v\n", scanner.Err())
Info("9 ERROR: %v\n", scanner.Err())
return nil
}

if shared.QuicConfiguration.Verbose {
log.Printf("%s\n", str.String())
if shared.QPepConfig.Verbose {
Info("%s\n", str.String())
}

respData := &StatsInfoReponse{}
jsonErr := json.Unmarshal(str.Bytes(), &respData)
if jsonErr != nil {
log.Printf("ERROR: %v\n", jsonErr)
Info("10 ERROR: %v\n", jsonErr)
return nil
}

Expand Down
Loading

0 comments on commit 4f163d0

Please sign in to comment.