From bf2f6e6a453cce9e039ad30e8dab41b740464961 Mon Sep 17 00:00:00 2001
From: "Meysam P. Ganji"
Date: Mon, 23 Aug 2021 20:14:34 +0430
Subject: [PATCH] make go mod as dependency manager
---
.github/workflows/go.yml | 28 +++++++++++++
.github/workflows/release.yml | 34 +++++++++++++++
README.md | 40 +++++++++---------
client/Configuration.go | 4 +-
client/HttpClient.go | 5 ++-
client/Initialize.go | 7 ++--
client/Notification.go | 5 ++-
client/addCallbackInformation.go | 2 +-
client/callCallbackOnRecieveDataFromServer.go | 3 +-
client/doActionOnReceivingDataFromServer.go | 5 ++-
client/doRequestPacketAction.go | 5 ++-
client/doRouteCallbackPacketAction.go | 5 ++-
client/doStringPacketAction.go | 5 ++-
client/getAndRegisterUserOnServer.go | 2 +-
client/getUserCommandsAndSendThemToServer.go | 4 +-
client/listUserRoutesAndCallbacksInATable.go | 4 +-
client/registerUserConnectionOnServer.go | 1 +
client/sendRequestToLocalRoute.go | 5 ++-
client/syncCallbackInformationWithServer.go | 1 +
common/GetInformationOfRequest.go | 2 +-
common/PrepareRequestToSend.go | 3 +-
common/PrepareRouteCallback.go | 2 +-
common/ReceiveDataFromConnection.go | 2 +-
common/SendDataToConnection.go | 2 +-
configurator/info.go | 35 ++++++++++++++++
glide.lock | 42 -------------------
glide.yaml | 11 -----
go.mod | 16 +++++++
go.sum | 41 ++++++++++++++++++
logger/Initialize.go | 9 ++--
main.go | 10 +++--
server/callbacker.go | 9 ++--
server/doRequestPacketAction.go | 3 +-
server/doRouteCallbackPacketAction.go | 3 +-
server/doStringPacketAction.go | 3 +-
server/forwardRequestToUser.go | 3 +-
server/getMessageFromClient.go | 1 +
server/hello.go | 4 +-
server/initialize.go | 4 +-
server/muxRouter.go | 5 ++-
server/registerCallback.go | 3 +-
storage/Memory.go | 4 +-
storage/types.go | 2 +-
43 files changed, 253 insertions(+), 131 deletions(-)
create mode 100644 .github/workflows/go.yml
create mode 100644 .github/workflows/release.yml
create mode 100644 configurator/info.go
delete mode 100644 glide.lock
delete mode 100644 glide.yaml
create mode 100644 go.mod
create mode 100644 go.sum
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
new file mode 100644
index 0000000..bf82c8a
--- /dev/null
+++ b/.github/workflows/go.yml
@@ -0,0 +1,28 @@
+name: Go
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+ steps:
+ - name: Set up Go 1.x
+ uses: actions/setup-go@v2
+ with:
+ go-version: ^1.14
+ id: go
+
+ - name: Check out code into the Go module directory
+ uses: actions/checkout@v2
+
+ - name: Get dependencies
+ run: |
+ go get -v -t -d ./...
+ - name: Build
+ run: go build -v .
\ No newline at end of file
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..fe9f8a3
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,34 @@
+# .github/workflows/release.yaml
+
+name: Build Release
+on:
+ release:
+ types: [ created ]
+
+jobs:
+ releases-matrix:
+ name: Release Go Binary
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ goos: [ linux ]
+ goarch: [ "386", arm, amd64 ]
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set APP_VERSION env
+ run: echo "APP_VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev )" >> $GITHUB_ENV
+
+ - name: Set BUILD_TIME env
+ run: echo "BUILD_TIME=$(date --rfc-3339=seconds | sed 's/ /T/')" >> $GITHUB_ENV
+
+ - uses: wangyoucao577/go-release-action@master
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ goos: ${{ matrix.goos }}
+ goarch: ${{ matrix.goarch }}
+ goversion: "https://dl.google.com/go/go1.15.2.linux-amd64.tar.gz"
+ project_path: "./"
+ binary_name: "callbacker"
+ extra_files: "README.md"
+ ldflags: -X "github.com/YasnaTeam/callbacker/configurator.AppVersion=${{ env.APP_VERSION }}" -X "github.com/YasnaTeam/callbacker/configurator.BuildTime=${{ env.BUILD_TIME }}" -X github.com/YasnaTeam/callbacker/configurator.GitCommit=${{ github.sha }} -s -w
\ No newline at end of file
diff --git a/README.md b/README.md
index dccc8de..ec97960 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,15 @@
# Callbacker :calling:
-Callbacker is a utility for creating fake :hear_no_evil: callback URLs. Suppose you are working on a service which needs some callback calls from other services (like github or google). Then the main problem is getting callbacks on the `localhost` without any valid IP or URL :no_entry:. Callbacker is answer to that problem :ok_hand:.
-
-
+Callbacker is a utility for creating fake :hear_no_evil: callback URLs. Suppose you are working on a service which needs
+some callback calls from other services (like github or google). Then the main problem is getting callbacks on
+the `localhost` without any valid IP or URL :no_entry:. Callbacker is answer to that problem :ok_hand:.
## Installing :computer:
### Direct method :arrow_double_down:
-Get executable package from [latest release](https://github.com/YasnaTeam/callbacker/releases/latest) page and make it executable on your system.
+Get executable package from [latest release](https://github.com/YasnaTeam/callbacker/releases/latest) page and make it
+executable on your system.
### Via GO! :1st_place_medal:
@@ -18,17 +19,16 @@ Run this command
go get https://github.com/YasnaTeam/callbacker
```
-
-
## Terminology :arrow_heading_down:
-Callbacker contains two part: `server` and `client`. `server` is one which register user connections, get their requests for callback definition and finally forward callback requests to `client`. `client` is the end user tools which can register callback, get forwarded request and send them to final destination.
-
-
+Callbacker contains two part: `server` and `client`. `server` is one which register user connections, get their requests
+for callback definition and finally forward callback requests to `client`. `client` is the end user tools which can
+register callback, get forwarded request and send them to final destination.
### Running a `server` instance :construction_worker:
-Suppose your final domain is `http://domain.ltd`, first you must define an endpoint with `/callback` URI. On `Nginx` you can do that with some configurations like this:
+Suppose your final domain is `http://domain.ltd`, first you must define an endpoint with `/callback` URI. On `Nginx` you
+can do that with some configurations like this:
```nginx
server {
@@ -46,8 +46,6 @@ then run the `server`:
./callbacker -v -s -u http://domain.ltd/callback
```
-
-
#### Defining a `systemd` service for server instance
For definition of a `systemd` service, you can create a file on `~/.config/systemd/user` and put this lines on it:
@@ -68,12 +66,8 @@ RestartSec=5s
then reload daemons with `systemctl daemon-reload` and run the service with `systemctl start callbacker`.
-
-
With `./callbacker -h` you can see all available flags.
-
-
### Running a `client` instance :post_office:
In your local command line, just run this:
@@ -102,7 +96,8 @@ Use this commands:
x (or exit) Exit from program
```
-by pressing `a` you can add a local route to callbacker. Local route is an endpoint on your software which wanna receive information (for example from a github webhook or after logging in on google):
+by pressing `a` you can add a local route to callbacker. Local route is an endpoint on your software which wanna receive
+information (for example from a github webhook or after logging in on google):
```bash
$ ./callbacker -c domain.ltd:2424
@@ -123,10 +118,13 @@ Please select a command (Press h for help): l
1 http://mysite.mpg/api/v1/my_endpoint http://domain.ltd/callback/b5b1c30a-57e2-428e-861e-813d9a92fc0f
```
-Now you can use `http://domain.ltd/callback/b5b1c30a-57e2-428e-861e-813d9a92fc0f` as a valid URL and pass it to origin (e.g. github webhook, ...). Each time a callback has been called to this URL, all information of request will be sent to your running client and a callback will be simulated.
-
-
+Now you can use `http://domain.ltd/callback/b5b1c30a-57e2-428e-861e-813d9a92fc0f` as a valid URL and pass it to origin (
+e.g. github webhook, ...). Each time a callback has been called to this URL, all information of request will be sent to
+your running client and a callback will be simulated.
## Contribution :love_letter:
-Fork from this project :fork_and_knife:,use [glide](http://glide.sh/) as package manager, do your modification and send a pull request! Also all issues are welcome! :heart:
\ No newline at end of file
+Fork from this project :fork_and_knife:, do your modification and send a pull request!
+
+---------
+Made with love in [YasnaTeam](https://yasna.team) :heart:
\ No newline at end of file
diff --git a/client/Configuration.go b/client/Configuration.go
index 9941e9b..557a479 100644
--- a/client/Configuration.go
+++ b/client/Configuration.go
@@ -1,8 +1,8 @@
package client
import (
- "os"
"encoding/json"
+ "os"
)
type Configuration struct {
@@ -78,4 +78,4 @@ func saveConfiguration(configuration *Configuration) error {
}
return nil
-}
\ No newline at end of file
+}
diff --git a/client/HttpClient.go b/client/HttpClient.go
index 12db090..6deb066 100644
--- a/client/HttpClient.go
+++ b/client/HttpClient.go
@@ -1,10 +1,11 @@
package client
import (
+ "bytes"
+ "net/http"
+
"github.com/YasnaTeam/callbacker/common"
"github.com/gojektech/heimdall/httpclient"
- "net/http"
- "bytes"
)
type Client struct {
diff --git a/client/Initialize.go b/client/Initialize.go
index f9e8b20..3a3edbf 100644
--- a/client/Initialize.go
+++ b/client/Initialize.go
@@ -1,9 +1,10 @@
package client
import (
- "github.com/sirupsen/logrus"
"net"
+
"github.com/YasnaTeam/callbacker/storage"
+ "github.com/sirupsen/logrus"
)
var log *logrus.Logger
@@ -11,7 +12,7 @@ var username string
var routes storage.RouteTable // map callback url to route
var configuration *Configuration
-func Initialize(address string, logger *logrus.Logger, notification func (title, text string)) {
+func Initialize(address string, logger *logrus.Logger, notification func(title, text string)) {
log = logger
log.Info("Client started...")
@@ -41,7 +42,7 @@ func Initialize(address string, logger *logrus.Logger, notification func (title,
} else {
log.Debugf("User `%s` has been selected from configurations file.", configuration.Username)
registerUserOnServer(conn, configuration.Username)
- setSavedCallbacksOnClientRouteTable();
+ setSavedCallbacksOnClientRouteTable()
}
// All receiving of data is handled by this function
diff --git a/client/Notification.go b/client/Notification.go
index 78abab0..e5d655d 100644
--- a/client/Notification.go
+++ b/client/Notification.go
@@ -1,9 +1,10 @@
package client
import (
- "runtime"
- "os/exec"
"fmt"
+ "os/exec"
+ "runtime"
+
"github.com/sirupsen/logrus"
)
diff --git a/client/addCallbackInformation.go b/client/addCallbackInformation.go
index ec5338e..6d839d3 100644
--- a/client/addCallbackInformation.go
+++ b/client/addCallbackInformation.go
@@ -1,6 +1,6 @@
package client
-func addCallbackInformation(result, route string, notification func (title, text string)) {
+func addCallbackInformation(result, route string, notification func(title, text string)) {
routes.Set(result, route)
configuration.AddRouteCallback(route, result)
diff --git a/client/callCallbackOnRecieveDataFromServer.go b/client/callCallbackOnRecieveDataFromServer.go
index 4c252db..35a0f9d 100644
--- a/client/callCallbackOnRecieveDataFromServer.go
+++ b/client/callCallbackOnRecieveDataFromServer.go
@@ -1,9 +1,10 @@
package client
import (
+ "fmt"
"net"
+
"github.com/YasnaTeam/callbacker/common"
- "fmt"
)
func callCallbackOnRecieveDataFromServer(conn net.Conn) {
diff --git a/client/doActionOnReceivingDataFromServer.go b/client/doActionOnReceivingDataFromServer.go
index e59ff9c..a15cf7a 100644
--- a/client/doActionOnReceivingDataFromServer.go
+++ b/client/doActionOnReceivingDataFromServer.go
@@ -2,11 +2,12 @@ package client
import (
"net"
- "github.com/YasnaTeam/callbacker/common"
"os"
+
+ "github.com/YasnaTeam/callbacker/common"
)
-func doActionOnReceivingDataFromServer(conn net.Conn, notification func (title, text string)) {
+func doActionOnReceivingDataFromServer(conn net.Conn, notification func(title, text string)) {
for {
packet, err := common.ReceiveDataFromConnection(conn)
if err != nil {
diff --git a/client/doRequestPacketAction.go b/client/doRequestPacketAction.go
index fcb9bb9..6cd1884 100644
--- a/client/doRequestPacketAction.go
+++ b/client/doRequestPacketAction.go
@@ -1,11 +1,12 @@
package client
import (
- "github.com/YasnaTeam/callbacker/common"
"net"
+
+ "github.com/YasnaTeam/callbacker/common"
)
-func doRequestPacketAction(conn net.Conn, tr *common.TransferableRequest, notification func (title, text string)) {
+func doRequestPacketAction(conn net.Conn, tr *common.TransferableRequest, notification func(title, text string)) {
data := tr.GetData().(*common.Request)
switch tr.GetCommand() {
case "callback_forward":
diff --git a/client/doRouteCallbackPacketAction.go b/client/doRouteCallbackPacketAction.go
index d02f23e..d2a425b 100644
--- a/client/doRouteCallbackPacketAction.go
+++ b/client/doRouteCallbackPacketAction.go
@@ -1,11 +1,12 @@
package client
import (
- "github.com/YasnaTeam/callbacker/common"
"net"
+
+ "github.com/YasnaTeam/callbacker/common"
)
-func doRouteCallbackPacketAction(conn net.Conn, rc *common.TransferableRouteCallback, domain string, notification func (title, text string)) {
+func doRouteCallbackPacketAction(conn net.Conn, rc *common.TransferableRouteCallback, domain string, notification func(title, text string)) {
data := rc.GetData().(*common.RouteCallback)
switch rc.GetCommand() {
case "callback_information":
diff --git a/client/doStringPacketAction.go b/client/doStringPacketAction.go
index cf2df27..4f159ef 100644
--- a/client/doStringPacketAction.go
+++ b/client/doStringPacketAction.go
@@ -1,11 +1,12 @@
package client
import (
- "github.com/YasnaTeam/callbacker/common"
"net"
+
+ "github.com/YasnaTeam/callbacker/common"
)
-func doStringPacketAction(conn net.Conn, ts *common.TransferableString, notification func (title, text string)) {
+func doStringPacketAction(conn net.Conn, ts *common.TransferableString, notification func(title, text string)) {
//data := ts.GetData().(string)
switch ts.GetCommand() {
case "register_user":
diff --git a/client/getAndRegisterUserOnServer.go b/client/getAndRegisterUserOnServer.go
index d58ae88..31b7b69 100644
--- a/client/getAndRegisterUserOnServer.go
+++ b/client/getAndRegisterUserOnServer.go
@@ -2,9 +2,9 @@ package client
import (
"bufio"
- "os"
"fmt"
"net"
+ "os"
)
func getAndRegisterUserOnServer(conn net.Conn) (string, error) {
diff --git a/client/getUserCommandsAndSendThemToServer.go b/client/getUserCommandsAndSendThemToServer.go
index e369a11..79ae431 100644
--- a/client/getUserCommandsAndSendThemToServer.go
+++ b/client/getUserCommandsAndSendThemToServer.go
@@ -1,10 +1,10 @@
package client
import (
- "net"
"bufio"
- "os"
"fmt"
+ "net"
+ "os"
)
func getUserCommandsAndSendThemToServer(conn net.Conn) {
diff --git a/client/listUserRoutesAndCallbacksInATable.go b/client/listUserRoutesAndCallbacksInATable.go
index 6fba668..25f34d9 100644
--- a/client/listUserRoutesAndCallbacksInATable.go
+++ b/client/listUserRoutesAndCallbacksInATable.go
@@ -1,9 +1,9 @@
package client
import (
- "text/tabwriter"
- "os"
"fmt"
+ "os"
+ "text/tabwriter"
)
func listUserRoutesAndCallbacksInATable() {
diff --git a/client/registerUserConnectionOnServer.go b/client/registerUserConnectionOnServer.go
index d7a4068..3d870a0 100644
--- a/client/registerUserConnectionOnServer.go
+++ b/client/registerUserConnectionOnServer.go
@@ -2,6 +2,7 @@ package client
import (
"net"
+
"github.com/YasnaTeam/callbacker/common"
)
diff --git a/client/sendRequestToLocalRoute.go b/client/sendRequestToLocalRoute.go
index 0a87d61..8208911 100644
--- a/client/sendRequestToLocalRoute.go
+++ b/client/sendRequestToLocalRoute.go
@@ -1,11 +1,12 @@
package client
import (
- "github.com/YasnaTeam/callbacker/common"
"fmt"
+
+ "github.com/YasnaTeam/callbacker/common"
)
-func sendRequestToLocalRoute(r *common.Request, notification func (title, text string)) {
+func sendRequestToLocalRoute(r *common.Request, notification func(title, text string)) {
hc := NewHttpClient(r)
err := hc.SendRequest()
diff --git a/client/syncCallbackInformationWithServer.go b/client/syncCallbackInformationWithServer.go
index 99e69d1..cff15d3 100644
--- a/client/syncCallbackInformationWithServer.go
+++ b/client/syncCallbackInformationWithServer.go
@@ -2,6 +2,7 @@ package client
import (
"net"
+
"github.com/YasnaTeam/callbacker/common"
)
diff --git a/common/GetInformationOfRequest.go b/common/GetInformationOfRequest.go
index a135aac..38b59ca 100644
--- a/common/GetInformationOfRequest.go
+++ b/common/GetInformationOfRequest.go
@@ -24,4 +24,4 @@ func generateCallback(domain, callback string) string {
callbackInformation := strings.Split(callback, "/")
return domain + "/" + callbackInformation[1]
-}
\ No newline at end of file
+}
diff --git a/common/PrepareRequestToSend.go b/common/PrepareRequestToSend.go
index ca60c4a..d4ab832 100644
--- a/common/PrepareRequestToSend.go
+++ b/common/PrepareRequestToSend.go
@@ -1,8 +1,9 @@
package common
import (
- "vuvuzela.io/alpenhorn/log"
"net/http"
+
+ "vuvuzela.io/alpenhorn/log"
)
func PrepareRequestToSend(r *http.Request, domain string) ([]byte, error) {
diff --git a/common/PrepareRouteCallback.go b/common/PrepareRouteCallback.go
index a9117a0..692a2e7 100644
--- a/common/PrepareRouteCallback.go
+++ b/common/PrepareRouteCallback.go
@@ -4,4 +4,4 @@ func PrepareRouteCallback(route, callback, command string) ([]byte, error) {
b, err := GetByteFromTransferable(&TransferableRouteCallback{command, &RouteCallback{route, callback}})
return b, err
-}
\ No newline at end of file
+}
diff --git a/common/ReceiveDataFromConnection.go b/common/ReceiveDataFromConnection.go
index 02ab0e8..56d9b46 100644
--- a/common/ReceiveDataFromConnection.go
+++ b/common/ReceiveDataFromConnection.go
@@ -1,8 +1,8 @@
package common
import (
- "net"
"encoding/binary"
+ "net"
)
func ReceiveDataFromConnection(conn net.Conn) ([]byte, error) {
diff --git a/common/SendDataToConnection.go b/common/SendDataToConnection.go
index d45add5..07bfebc 100644
--- a/common/SendDataToConnection.go
+++ b/common/SendDataToConnection.go
@@ -1,8 +1,8 @@
package common
import (
- "net"
"encoding/binary"
+ "net"
)
func SendDataToConnection(conn net.Conn, b []byte) (int, error) {
diff --git a/configurator/info.go b/configurator/info.go
new file mode 100644
index 0000000..ba20b86
--- /dev/null
+++ b/configurator/info.go
@@ -0,0 +1,35 @@
+package configurator
+
+import (
+ "fmt"
+ "time"
+)
+
+var (
+ AppVersion string
+ BuildTime string
+ GitCommit string
+)
+
+const cb = ` ▄████████ ▀█████████▄
+███ ███ ███ ███
+███ █▀ ███ ███
+███ ▄███▄▄▄██▀
+███ ▀▀███▀▀▀██▄
+███ █▄ ███ ██▄
+███ ███ ███ ███
+████████▀ ▄█████████▀ `
+
+func PrintBuildInformation() {
+ buildDate, _ := time.Parse(time.RFC3339, BuildTime)
+
+ fmt.Println(cb)
+ fmt.Printf(
+ "Version:\t\t%s\n"+
+ "Build Commit:\t\t%s\n"+
+ "Build Date:\t\t%s\n",
+ AppVersion,
+ GitCommit,
+ buildDate.UTC(),
+ )
+}
diff --git a/glide.lock b/glide.lock
deleted file mode 100644
index 8481a43..0000000
--- a/glide.lock
+++ /dev/null
@@ -1,42 +0,0 @@
-hash: 69f91b07e7b5ae7262d5f0e2a695e1485b0b1c6acc91d76cbda1b360098ff79e
-updated: 2018-08-02T16:41:01.169612942+04:30
-imports:
-- name: github.com/davidlazar/go-crypto
- version: dcfb0a7ac018a248366f96bcd8a2f8c805d7b268
- subpackages:
- - encoding/base32
-- name: github.com/gojektech/heimdall
- version: 54d43c53c27af9aaedbc8cff538ee523a8973bda
- subpackages:
- - httpclient
-- name: github.com/gojektech/valkyrie
- version: b19510f6c63cc7dd1c9d67708e28d5ff18f49351
-- name: github.com/gorilla/context
- version: 08b5f424b9271eedf6f9f0ce86cb9396ed337a42
-- name: github.com/gorilla/mux
- version: e3702bed27f0d39777b0b37b664b6280e8ef8fbf
-- name: github.com/mattn/go-isatty
- version: 6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c
-- name: github.com/pkg/errors
- version: 816c9085562cd7ee03e7f8188a1cfd942858cded
-- name: github.com/satori/go.uuid
- version: f58768cc1a7a7e77a3bd49e98cdd21419399b6a3
-- name: github.com/sirupsen/logrus
- version: 3e01752db0189b9157070a0e1668a620f9a85da2
-- name: github.com/t-tomalak/logrus-easy-formatter
- version: ca9ce6b071ebe774296872e9dff2009b87ddcbb0
-- name: golang.org/x/crypto
- version: c126467f60eb25f8f27e5a981f32a87e3965053f
- subpackages:
- - ssh/terminal
-- name: golang.org/x/sys
- version: 3dc4335d56c789b04b0ba99b7a37249d9b614314
- subpackages:
- - unix
- - windows
-- name: vuvuzela.io/alpenhorn
- version: 80fdff195936d4b843c562b844bc5c8f0ba57d63
- subpackages:
- - log
- - log/ansi
-testImports: []
diff --git a/glide.yaml b/glide.yaml
deleted file mode 100644
index 03e00db..0000000
--- a/glide.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-package: github.com/YasnaTeam/callbacker
-import:
-- package: github.com/sirupsen/logrus
- version: ^1.0.6
-- package: github.com/t-tomalak/logrus-easy-formatter
-- package: github.com/gorilla/mux
- version: ^1.6.2
-- package: github.com/satori/go.uuid
- version: ^1.2.0
-- package: github.com/gojektech/heimdall
- version: ^4.1.0
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..e4a9ac2
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,16 @@
+module github.com/YasnaTeam/callbacker
+
+go 1.16
+
+require (
+ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
+ github.com/gojektech/heimdall v4.2.0+incompatible
+ github.com/gojektech/valkyrie v0.0.0-20190210220504-8f62c1e7ba45 // indirect
+ github.com/gorilla/mux v1.8.0
+ github.com/mattn/go-isatty v0.0.13 // indirect
+ github.com/pkg/errors v0.9.1 // indirect
+ github.com/satori/go.uuid v1.2.0
+ github.com/sirupsen/logrus v1.8.1
+ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
+ vuvuzela.io/alpenhorn v0.0.0-20190912152808-6b33518f681e
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..47cdb19
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,41 @@
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR6AkioZ1ySsx5yxlDQZ8stG2b88gTPxgJU=
+github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U=
+github.com/gojektech/heimdall v4.2.0+incompatible h1:rNAspvEwSTWAx89B68BmXBo1q7xflJWVladkuoL2MRc=
+github.com/gojektech/heimdall v4.2.0+incompatible/go.mod h1:8hRIZ3+Kz0r3GAFI9QrUuvZht8ypg5Rs8schCXioLOo=
+github.com/gojektech/valkyrie v0.0.0-20190210220504-8f62c1e7ba45 h1:MO2DsGCZz8phRhLnpFvHEQgTH521sVN/6F2GZTbNO3Q=
+github.com/gojektech/valkyrie v0.0.0-20190210220504-8f62c1e7ba45/go.mod h1:tDYRk1s5Pms6XJjj5m2PxAzmQvaDU8GqDf1u6x7yxKw=
+github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
+github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
+github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
+github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
+github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
+github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
+github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
+github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
+github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
+golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
+vuvuzela.io/alpenhorn v0.0.0-20190912152808-6b33518f681e h1:xNfW1LVymdiGhpuBb28xGy/ZOjYw4I/MAPtsw3IY/UQ=
+vuvuzela.io/alpenhorn v0.0.0-20190912152808-6b33518f681e/go.mod h1:3MH7kJUPecCgROizarAZV1SgN15OTYubMpk+Go6KMVc=
diff --git a/logger/Initialize.go b/logger/Initialize.go
index 9f7edd9..647e9ad 100644
--- a/logger/Initialize.go
+++ b/logger/Initialize.go
@@ -1,9 +1,10 @@
package logger
import (
- "github.com/sirupsen/logrus"
- "os"
"net/http"
+ "os"
+
+ "github.com/sirupsen/logrus"
)
//var log *Logger
@@ -30,8 +31,8 @@ func New(debug bool) *logrus.Logger {
func WithRequest(logger *logrus.Logger, r *http.Request) *logrus.Entry {
return logger.WithFields(logrus.Fields{
- "method": r.Method,
- "protocol": r.Proto,
+ "method": r.Method,
+ "protocol": r.Proto,
"remote_addr": r.RemoteAddr,
})
}
diff --git a/main.go b/main.go
index 62ff65f..b348c60 100644
--- a/main.go
+++ b/main.go
@@ -2,9 +2,11 @@ package main
import (
"flag"
- "github.com/YasnaTeam/callbacker/server"
+
"github.com/YasnaTeam/callbacker/client"
+ "github.com/YasnaTeam/callbacker/configurator"
"github.com/YasnaTeam/callbacker/logger"
+ "github.com/YasnaTeam/callbacker/server"
"github.com/sirupsen/logrus"
)
@@ -18,7 +20,6 @@ var logLocation string
var showNotification bool
var log *logrus.Logger
-
func init() {
flag.BoolVar(&isServer, "server", false, "make instance as a server")
flag.BoolVar(&isServer, "s", false, "make instance as a server")
@@ -46,11 +47,12 @@ func init() {
}
func main() {
+ configurator.PrintBuildInformation()
+
flag.Parse()
log = logger.New(debugMode)
log.Debug("log module fired up!")
-
if isServer {
server.Initialize(serverLocalAddress, serverPort, serverRepresentationalMainUrl, log)
} else {
@@ -59,4 +61,4 @@ func main() {
}
log.Info("Shutting down...")
-}
\ No newline at end of file
+}
diff --git a/server/callbacker.go b/server/callbacker.go
index adab35e..ddfdd3e 100644
--- a/server/callbacker.go
+++ b/server/callbacker.go
@@ -1,10 +1,11 @@
package server
import (
- "net/http"
- "github.com/YasnaTeam/callbacker/logger"
"net"
+ "net/http"
"strings"
+
+ "github.com/YasnaTeam/callbacker/logger"
)
func callbacker(w http.ResponseWriter, r *http.Request, domain string) {
@@ -23,9 +24,9 @@ func callbacker(w http.ResponseWriter, r *http.Request, domain string) {
conn, err := connections.Get(username.(string))
if err != nil {
- log.Debug("No alive connection found related to `" + username.(string) +"`.")
+ log.Debug("No alive connection found related to `" + username.(string) + "`.")
return
}
forwardRequestToUser(conn.(net.Conn), r, domain)
-}
\ No newline at end of file
+}
diff --git a/server/doRequestPacketAction.go b/server/doRequestPacketAction.go
index 301c01c..0836e52 100644
--- a/server/doRequestPacketAction.go
+++ b/server/doRequestPacketAction.go
@@ -1,8 +1,9 @@
package server
import (
- "github.com/YasnaTeam/callbacker/common"
"net"
+
+ "github.com/YasnaTeam/callbacker/common"
)
func doRequestPacketAction(conn net.Conn, tr *common.TransferableRequest) {
diff --git a/server/doRouteCallbackPacketAction.go b/server/doRouteCallbackPacketAction.go
index 3061c9a..a4a5048 100644
--- a/server/doRouteCallbackPacketAction.go
+++ b/server/doRouteCallbackPacketAction.go
@@ -1,8 +1,9 @@
package server
import (
- "github.com/YasnaTeam/callbacker/common"
"net"
+
+ "github.com/YasnaTeam/callbacker/common"
)
func doRouteCallbackPacketAction(conn net.Conn, rc *common.TransferableRouteCallback, domain string) {
diff --git a/server/doStringPacketAction.go b/server/doStringPacketAction.go
index 77aef61..6bdd642 100644
--- a/server/doStringPacketAction.go
+++ b/server/doStringPacketAction.go
@@ -1,8 +1,9 @@
package server
import (
- "github.com/YasnaTeam/callbacker/common"
"net"
+
+ "github.com/YasnaTeam/callbacker/common"
)
func doStringPacketAction(conn net.Conn, ts *common.TransferableString) {
diff --git a/server/forwardRequestToUser.go b/server/forwardRequestToUser.go
index 5f0e5c3..9658fd2 100644
--- a/server/forwardRequestToUser.go
+++ b/server/forwardRequestToUser.go
@@ -3,6 +3,7 @@ package server
import (
"net"
"net/http"
+
"github.com/YasnaTeam/callbacker/common"
)
@@ -22,6 +23,6 @@ func forwardRequestToUser(conn net.Conn, r *http.Request, domain string) error {
}
log.Debugf("%d bytes as a forwarded request has been sent to user.", bs)
-
+
return nil
}
diff --git a/server/getMessageFromClient.go b/server/getMessageFromClient.go
index 1e095d5..eb668b7 100644
--- a/server/getMessageFromClient.go
+++ b/server/getMessageFromClient.go
@@ -2,6 +2,7 @@ package server
import (
"net"
+
"github.com/YasnaTeam/callbacker/common"
)
diff --git a/server/hello.go b/server/hello.go
index 7697608..fddc20c 100644
--- a/server/hello.go
+++ b/server/hello.go
@@ -1,12 +1,12 @@
package server
import (
- "net/http"
"io"
+ "net/http"
)
func hello(w http.ResponseWriter, r *http.Request) {
log.Debug("Handler `hello` has been ran.")
//requestlog := logger.WithRequest(log, r)
io.WriteString(w, "Hello World!")
-}
\ No newline at end of file
+}
diff --git a/server/initialize.go b/server/initialize.go
index 197a19a..9cd3070 100644
--- a/server/initialize.go
+++ b/server/initialize.go
@@ -1,12 +1,12 @@
package server
import (
- "github.com/sirupsen/logrus"
"github.com/YasnaTeam/callbacker/storage"
+ "github.com/sirupsen/logrus"
)
var log *logrus.Logger
-var routes storage.RouteTable // map routes to users
+var routes storage.RouteTable // map routes to users
var connections storage.RouteTable // map users to connections
func Initialize(address string, port string, serverUrl string, logger *logrus.Logger) {
diff --git a/server/muxRouter.go b/server/muxRouter.go
index f672753..c5c56e6 100644
--- a/server/muxRouter.go
+++ b/server/muxRouter.go
@@ -1,8 +1,9 @@
package server
import (
- "github.com/gorilla/mux"
"net/http"
+
+ "github.com/gorilla/mux"
)
func muxRouter(domain string) *mux.Router {
@@ -10,7 +11,7 @@ func muxRouter(domain string) *mux.Router {
r := mux.NewRouter()
r.HandleFunc("/hello", hello)
- r.HandleFunc("/callback/{route_token}", func (w http.ResponseWriter, r *http.Request) {
+ r.HandleFunc("/callback/{route_token}", func(w http.ResponseWriter, r *http.Request) {
callbacker(w, r, domain)
})
diff --git a/server/registerCallback.go b/server/registerCallback.go
index 3154335..f45772e 100644
--- a/server/registerCallback.go
+++ b/server/registerCallback.go
@@ -2,8 +2,9 @@ package server
import (
"net"
- uuid2 "github.com/satori/go.uuid"
+
"github.com/YasnaTeam/callbacker/common"
+ uuid2 "github.com/satori/go.uuid"
)
func registerCallback(conn net.Conn, rc *common.RouteCallback, domain string) {
diff --git a/storage/Memory.go b/storage/Memory.go
index 93cc46e..ce5265f 100644
--- a/storage/Memory.go
+++ b/storage/Memory.go
@@ -1,7 +1,7 @@
package storage
type MemoryTable struct {
- max uint
+ max uint
table map[string]interface{}
}
@@ -76,4 +76,4 @@ func (m *MemoryTable) Truncate() {
for i, _ := range m.All() {
m.Unset(i)
}
-}
\ No newline at end of file
+}
diff --git a/storage/types.go b/storage/types.go
index 86293ea..a6e2cc1 100644
--- a/storage/types.go
+++ b/storage/types.go
@@ -41,4 +41,4 @@ type CanNotSetError struct {
func (e *CanNotSetError) Error() string {
return e.reason
-}
\ No newline at end of file
+}