Skip to content

Commit

Permalink
GitHub workflow support
Browse files Browse the repository at this point in the history
  • Loading branch information
savely-krasovsky committed Mar 29, 2022
1 parent 9f9db59 commit 75a3d0e
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 65 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Go

on:
pull_request:
push:

permissions:
contents: write

jobs:
escobar:
runs-on: ubuntu-latest
steps:
- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: 1.18.x

- name: Setup modules cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/checkout@v2

- name: Download dependencies
run: go mod download

- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.45.2

- name: Build
run: go build ./cmd/escobar

- name: Test
run: go test -gcflags=all=-l -v ./...

- name: Test race
run: go test -gcflags=all=-l -race -v ./...

- name: Release
if: startsWith(github.ref, 'refs/tags/v')
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Goland (IDEA)
.idea
/.idea

# Personal testing config
configs/keytabs/personal.keytab
configs/personal.env

# Binaries
bin/
/dist/
escobar
escobar.exe
24 changes: 0 additions & 24 deletions .gitlab-ci.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
project_name: escobar

release:
github:
owner: L11R
name: escobar

builds:
- binary: escobar
goos:
- darwin
- windows
- linux
- freebsd
goarch:
- amd64
- arm64
- arm
- 386
- ppc64le
- s390x
- mips64
- mips64le
- riscv64
goarm:
- 6
- 7
gomips:
- hardfloat
env:
- CGO_ENABLED=0
ignore:
- goos: darwin
goarch: 386
- goos: freebsd
goarch: arm64
main: ./cmd/escobar/main.go
flags:
- -trimpath
ldflags: -s -w -X $(PROJECT)/internal/version.Version={{.Version}} -X $(PROJECT)/internal/version.Commit={{.ShortCommit}}

archives:
- format: tar.gz
wrap_in_directory: true
format_overrides:
- goos: windows
format: zip
name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
files:
- LICENSE
- README.md

snapshot:
name_template: SNAPSHOT-{{ .Commit }}

checksum:
name_template: '{{ .ProjectName }}-{{ .Version }}-checksums.txt'
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Changes with Escobar 3.0.0, 29 March 2022
*) Feature: service support (Windows tested, Unix and macOS should work too)
*) Feature: auto mode support for Linux (macOS not supported yet)
*) Change: code simplification and dependencies update
*) Bugfix: many small fixes

Changes with Escobar 2.2.0, 28 January 2020
*) Change: Windows now require only few arguments
*) Bugfix: Initialization logic changed, start is improved
Expand Down
23 changes: 0 additions & 23 deletions Makefile

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Escobar
[![Go](https://github.com/L11R/escobar/actions/workflows/go.yml/badge.svg)](https://github.com/L11R/escobar/actions/workflows/go.yml)

This is an alternative to `cntlm` utility, but written in Go. It's aim to be simpler and easier to customize
for own needs. Mainly tested against McAfee Web Gateway. Tested in Linux, macOS and Windows, but should work on other
OS like Android.
Expand Down
11 changes: 2 additions & 9 deletions internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ type Daemon struct {
}

func New() *Daemon {
d := &Daemon{
SystemLogger: nil,
logger: nil,
config: nil,
proxy: nil,
static: nil,
}

return d
return &Daemon{}
}

func (d *Daemon) Start(svc service.Service) error {
Expand Down Expand Up @@ -167,6 +159,7 @@ func (d *Daemon) run(svc service.Service) {
go func() {
if err := <-errChan; err != nil {
logger.Error("Error while running proxy!", zap.Error(err))
// nolint:errcheck
d.Stop(nil)
os.Exit(1)
}
Expand Down
1 change: 1 addition & 0 deletions internal/proxy/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestProxy_setProxyAuthorizationHeader(t *testing.T) {
if err != nil {
t.Fatal(err)
}
// nolint:errcheck
defer patch.Unpatch()
if err := p.setProxyAuthorizationHeader(req); err != nil {
assert.NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions internal/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func (p *Proxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
zap.String("user_agent", req.UserAgent()),
zap.String("uri", req.RequestURI),
)
// nolint:staticcheck
req = req.WithContext(context.WithValue(context.Background(), LogEntryCtx, logger))

defer func() {
Expand Down
1 change: 1 addition & 0 deletions internal/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func TestNewProxy(t *testing.T) {
patch := monkey.Patch(httputil.NewForwardingProxy, func() *httputil.ReverseProxy {
return rp
})
// nolint:errcheck
defer patch.Unpatch()

expected := &Proxy{
Expand Down
6 changes: 0 additions & 6 deletions internal/proxy/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package proxy

import (
"bytes"
"io"
"net"
"net/http"
"testing"
Expand All @@ -16,8 +15,6 @@ import (
"go.uber.org/zap"
)

// Copyright 2015 Google Inc. All rights reserved.

func Test_newResponse(t *testing.T) {
req, err := http.NewRequest("GET", "http://www.example.com", nil)
if err != nil {
Expand Down Expand Up @@ -47,9 +44,6 @@ func Test_newResponse(t *testing.T) {
if res.Header == nil {
t.Error("res.Header: got nil, want header")
}
if _, ok := res.Body.(io.ReadCloser); !ok {
t.Error("res.Body.(io.ReadCloser): got !ok, want ok")
}
if got, want := res.Request, req; got != want {
t.Errorf("res.Request: got %v, want %v", got, want)
}
Expand Down
1 change: 0 additions & 1 deletion version

This file was deleted.

0 comments on commit 75a3d0e

Please sign in to comment.