mirror of
https://github.com/bolkedebruin/rdpgw.git
synced 2026-03-27 22:46:37 +00:00
Add Makefile build
This prepares for multiple binaries and distribution builds
This commit is contained in:
68
Makefile
Normal file
68
Makefile
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
BINDIR := $(CURDIR)/bin
|
||||||
|
INSTALL_PATH ?= /usr/local/bin
|
||||||
|
DIST_DIRS := find * -type d -exec
|
||||||
|
TARGETS := darwin/amd64 darwin/arm64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x windows/amd64
|
||||||
|
TARGET_OBJS ?= darwin-amd64.tar.gz darwin-amd64.tar.gz.sha256 darwin-amd64.tar.gz.sha256sum darwin-arm64.tar.gz darwin-arm64.tar.gz.sha256 darwin-arm64.tar.gz.sha256sum linux-amd64.tar.gz linux-amd64.tar.gz.sha256 linux-amd64.tar.gz.sha256sum linux-386.tar.gz linux-386.tar.gz.sha256 linux-386.tar.gz.sha256sum linux-arm.tar.gz linux-arm.tar.gz.sha256 linux-arm.tar.gz.sha256sum linux-arm64.tar.gz linux-arm64.tar.gz.sha256 linux-arm64.tar.gz.sha256sum linux-ppc64le.tar.gz linux-ppc64le.tar.gz.sha256 linux-ppc64le.tar.gz.sha256sum linux-s390x.tar.gz linux-s390x.tar.gz.sha256 linux-s390x.tar.gz.sha256sum windows-amd64.zip windows-amd64.zip.sha256 windows-amd64.zip.sha256sum
|
||||||
|
BINNAME ?= rdpgw
|
||||||
|
|
||||||
|
# Rebuild the binary if any of these files change
|
||||||
|
SRC := $(shell find . -type f -name '*.go' -print) go.mod go.sum
|
||||||
|
|
||||||
|
# Required for globs to work correctly
|
||||||
|
SHELL = /usr/bin/env bash
|
||||||
|
|
||||||
|
GIT_COMMIT = $(shell git rev-parse HEAD)
|
||||||
|
GIT_SHA = $(shell git rev-parse --short HEAD)
|
||||||
|
GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
|
||||||
|
GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
|
||||||
|
|
||||||
|
ifdef VERSION
|
||||||
|
BINARY_VERSION = $(VERSION)
|
||||||
|
endif
|
||||||
|
BINARY_VERSION ?= ${GIT_TAG}
|
||||||
|
|
||||||
|
VERSION_METADATA = unreleased
|
||||||
|
# Clear the "unreleased" string in BuildMetadata
|
||||||
|
ifneq ($(GIT_TAG),)
|
||||||
|
VERSION_METADATA =
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: mod build
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# build
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: $(BINDIR)/$(BINNAME)
|
||||||
|
|
||||||
|
$(BINDIR)/$(BINNAME): $(SRC)
|
||||||
|
GOMODULE=on go build $(GOFLAGS) -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o '$(BINDIR)'/$(BINNAME) ./cmd/rdpgw
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# install
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: build
|
||||||
|
@install "$(BINDIR)/$(BINNAME)" "$(INSTALL_PATH)/$(BINNAME)"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# mod
|
||||||
|
|
||||||
|
.PHONY: mod
|
||||||
|
mod:
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# clean
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
@rm -rf '$(BINDIR)' ./_dist
|
||||||
|
|
||||||
|
.PHONY: info
|
||||||
|
info:
|
||||||
|
@echo "Version: ${VERSION}"
|
||||||
|
@echo "Git Tag: ${GIT_TAG}"
|
||||||
|
@echo "Git Commit: ${GIT_COMMIT}"
|
||||||
|
@echo "Git Tree State: ${GIT_DIRTY}"
|
||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bolkedebruin/rdpgw/security"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/security"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
@@ -3,11 +3,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"github.com/bolkedebruin/rdpgw/api"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/api"
|
||||||
"github.com/bolkedebruin/rdpgw/common"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/common"
|
||||||
"github.com/bolkedebruin/rdpgw/config"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/config"
|
||||||
"github.com/bolkedebruin/rdpgw/protocol"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/protocol"
|
||||||
"github.com/bolkedebruin/rdpgw/security"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/security"
|
||||||
"github.com/coreos/go-oidc/v3/oidc"
|
"github.com/coreos/go-oidc/v3/oidc"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -68,7 +68,7 @@ func main() {
|
|||||||
OIDCTokenVerifier: verifier,
|
OIDCTokenVerifier: verifier,
|
||||||
PAATokenGenerator: security.GeneratePAAToken,
|
PAATokenGenerator: security.GeneratePAAToken,
|
||||||
UserTokenGenerator: security.GenerateUserToken,
|
UserTokenGenerator: security.GenerateUserToken,
|
||||||
EnableUserToken: conf.Security.EnableUserToken,
|
EnableUserToken: conf.Security.EnableUserToken,
|
||||||
SessionKey: []byte(conf.Server.SessionKey),
|
SessionKey: []byte(conf.Server.SessionKey),
|
||||||
SessionEncryptionKey: []byte(conf.Server.SessionEncryptionKey),
|
SessionEncryptionKey: []byte(conf.Server.SessionEncryptionKey),
|
||||||
Hosts: conf.Server.Hosts,
|
Hosts: conf.Server.Hosts,
|
||||||
@@ -77,7 +77,7 @@ func main() {
|
|||||||
BandwidthAutoDetect: conf.Client.BandwidthAutoDetect,
|
BandwidthAutoDetect: conf.Client.BandwidthAutoDetect,
|
||||||
ConnectionType: conf.Client.ConnectionType,
|
ConnectionType: conf.Client.ConnectionType,
|
||||||
SplitUserDomain: conf.Client.SplitUserDomain,
|
SplitUserDomain: conf.Client.SplitUserDomain,
|
||||||
DefaultDomain: conf.Client.DefaultDomain,
|
DefaultDomain: conf.Client.DefaultDomain,
|
||||||
}
|
}
|
||||||
api.NewApi()
|
api.NewApi()
|
||||||
|
|
||||||
@@ -127,9 +127,9 @@ func main() {
|
|||||||
EnableAll: conf.Caps.RedirectAll,
|
EnableAll: conf.Caps.RedirectAll,
|
||||||
},
|
},
|
||||||
VerifyTunnelCreate: security.VerifyPAAToken,
|
VerifyTunnelCreate: security.VerifyPAAToken,
|
||||||
VerifyServerFunc: security.VerifyServerFunc,
|
VerifyServerFunc: security.VerifyServerFunc,
|
||||||
SendBuf: conf.Server.SendBuf,
|
SendBuf: conf.Server.SendBuf,
|
||||||
ReceiveBuf: conf.Server.ReceiveBuf,
|
ReceiveBuf: conf.Server.ReceiveBuf,
|
||||||
}
|
}
|
||||||
gw := protocol.Gateway{
|
gw := protocol.Gateway{
|
||||||
ServerConf: &handlerConfig,
|
ServerConf: &handlerConfig,
|
||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/bolkedebruin/rdpgw/transport"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/transport"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@@ -27,10 +27,10 @@ type SessionInfo struct {
|
|||||||
ConnId string
|
ConnId string
|
||||||
// The underlying incoming transport being either websocket or legacy http
|
// The underlying incoming transport being either websocket or legacy http
|
||||||
// in case of websocket TransportOut will equal TransportIn
|
// in case of websocket TransportOut will equal TransportIn
|
||||||
TransportIn transport.Transport
|
TransportIn transport.Transport
|
||||||
// The underlying outgoing transport being either websocket or legacy http
|
// The underlying outgoing transport being either websocket or legacy http
|
||||||
// in case of websocket TransportOut will equal TransportOut
|
// in case of websocket TransportOut will equal TransportOut
|
||||||
TransportOut transport.Transport
|
TransportOut transport.Transport
|
||||||
// The remote desktop server (rdp, vnc etc) the clients intends to connect to
|
// The remote desktop server (rdp, vnc etc) the clients intends to connect to
|
||||||
RemoteServer string
|
RemoteServer string
|
||||||
// The obtained client ip address
|
// The obtained client ip address
|
||||||
@@ -3,8 +3,8 @@ package protocol
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/bolkedebruin/rdpgw/common"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/common"
|
||||||
"github.com/bolkedebruin/rdpgw/transport"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/transport"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/patrickmn/go-cache"
|
"github.com/patrickmn/go-cache"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/bolkedebruin/rdpgw/common"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/common"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@@ -39,13 +39,13 @@ type ServerConf struct {
|
|||||||
IdleTimeout int
|
IdleTimeout int
|
||||||
SmartCardAuth bool
|
SmartCardAuth bool
|
||||||
TokenAuth bool
|
TokenAuth bool
|
||||||
ReceiveBuf int
|
ReceiveBuf int
|
||||||
SendBuf int
|
SendBuf int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(s *SessionInfo, conf *ServerConf) *Server {
|
func NewServer(s *SessionInfo, conf *ServerConf) *Server {
|
||||||
h := &Server{
|
h := &Server{
|
||||||
State: SERVER_STATE_INITIAL,
|
State: SERVER_STATE_INITIAL,
|
||||||
Session: s,
|
Session: s,
|
||||||
RedirectFlags: makeRedirectFlags(conf.RedirectFlags),
|
RedirectFlags: makeRedirectFlags(conf.RedirectFlags),
|
||||||
IdleTimeout: conf.IdleTimeout,
|
IdleTimeout: conf.IdleTimeout,
|
||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bolkedebruin/rdpgw/common"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/common"
|
||||||
"github.com/bolkedebruin/rdpgw/protocol"
|
"github.com/bolkedebruin/rdpgw/cmd/rdpgw/protocol"
|
||||||
"github.com/coreos/go-oidc/v3/oidc"
|
"github.com/coreos/go-oidc/v3/oidc"
|
||||||
"github.com/square/go-jose/v3"
|
"github.com/square/go-jose/v3"
|
||||||
"github.com/square/go-jose/v3/jwt"
|
"github.com/square/go-jose/v3/jwt"
|
||||||
Reference in New Issue
Block a user