mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-05-30 08:59:43 +00:00
Merge remote-tracking branch 'upstream/master'
# Conflicts: # internal/server/server.go
This commit is contained in:
271
.golangci.yml
Normal file
271
.golangci.yml
Normal file
@@ -0,0 +1,271 @@
|
||||
version: "2"
|
||||
|
||||
run:
|
||||
timeout: 5m
|
||||
tests: true
|
||||
build-tags:
|
||||
- race
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- errcheck
|
||||
- govet
|
||||
- staticcheck
|
||||
- unused
|
||||
- ineffassign
|
||||
- asasalint
|
||||
- asciicheck
|
||||
- bidichk
|
||||
- bodyclose
|
||||
- canonicalheader
|
||||
- containedctx
|
||||
- contextcheck
|
||||
- copyloopvar
|
||||
- cyclop
|
||||
- decorder
|
||||
- dogsled
|
||||
- dupl
|
||||
- dupword
|
||||
- durationcheck
|
||||
- err113
|
||||
- errchkjson
|
||||
- errname
|
||||
- errorlint
|
||||
- exhaustive
|
||||
- fatcontext
|
||||
- forbidigo
|
||||
- forcetypeassert
|
||||
- gocheckcompilerdirectives
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
- gochecksumtype
|
||||
- gocognit
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- godot
|
||||
- godox
|
||||
- goprintffuncname
|
||||
- gosec
|
||||
- grouper
|
||||
- iface
|
||||
- inamedparam
|
||||
- interfacebloat
|
||||
- intrange
|
||||
- ireturn
|
||||
- lll
|
||||
- loggercheck
|
||||
- maintidx
|
||||
- makezero
|
||||
- mirror
|
||||
- misspell
|
||||
- musttag
|
||||
- nakedret
|
||||
- nestif
|
||||
- nilerr
|
||||
- nilnesserr
|
||||
- nilnil
|
||||
- noctx
|
||||
- nolintlint
|
||||
- nonamedreturns
|
||||
- nosprintfhostport
|
||||
- perfsprint
|
||||
- prealloc
|
||||
- predeclared
|
||||
- promlinter
|
||||
- reassign
|
||||
- recvcheck
|
||||
- revive
|
||||
- rowserrcheck
|
||||
- sloglint
|
||||
- spancheck
|
||||
- sqlclosecheck
|
||||
- tagalign
|
||||
- tagliatelle
|
||||
- testableexamples
|
||||
- testifylint
|
||||
- thelper
|
||||
- tparallel
|
||||
- unconvert
|
||||
- unparam
|
||||
- usestdlibvars
|
||||
- wastedassign
|
||||
- whitespace
|
||||
- wrapcheck
|
||||
- zerologlint
|
||||
|
||||
linters-settings:
|
||||
errcheck:
|
||||
check-blank: true
|
||||
check-type-assertions: true
|
||||
exclude-functions:
|
||||
- (io.Closer).Close
|
||||
|
||||
govet:
|
||||
enable-all: true
|
||||
settings:
|
||||
shadow:
|
||||
strict: true
|
||||
|
||||
gosec:
|
||||
severity: medium
|
||||
confidence: medium
|
||||
excludes:
|
||||
- G104
|
||||
- G114
|
||||
|
||||
gocritic:
|
||||
enabled-tags:
|
||||
- diagnostic
|
||||
- style
|
||||
- performance
|
||||
- experimental
|
||||
- opinionated
|
||||
|
||||
revive:
|
||||
severity: warning
|
||||
enable-all-rules: false
|
||||
rules:
|
||||
- name: atomic
|
||||
- name: blank-imports
|
||||
- name: bool-literal-in-expr
|
||||
- name: call-to-gc
|
||||
- name: constant-logical-expr
|
||||
- name: context-as-argument
|
||||
- name: context-keys-type
|
||||
- name: datarace
|
||||
- name: defer
|
||||
- name: dot-imports
|
||||
- name: duplicated-imports
|
||||
- name: early-return
|
||||
- name: empty-block
|
||||
- name: empty-lines
|
||||
- name: error-naming
|
||||
- name: error-return
|
||||
- name: error-strings
|
||||
- name: errorf
|
||||
- name: exported
|
||||
- name: identical-branches
|
||||
- name: if-return
|
||||
- name: increment-decrement
|
||||
- name: indent-error-flow
|
||||
- name: modifies-parameter
|
||||
- name: modifies-value-receiver
|
||||
- name: range
|
||||
- name: range-val-address
|
||||
- name: range-val-in-closure
|
||||
- name: receiver-naming
|
||||
- name: redefines-builtin-id
|
||||
- name: string-of-int
|
||||
- name: struct-tag
|
||||
- name: superfluous-else
|
||||
- name: time-equal
|
||||
- name: time-naming
|
||||
- name: unconditional-recursion
|
||||
- name: unexported-naming
|
||||
- name: unexported-return
|
||||
- name: unhandled-error
|
||||
- name: unnecessary-stmt
|
||||
- name: unreachable-code
|
||||
- name: unused-parameter
|
||||
- name: unused-receiver
|
||||
- name: use-any
|
||||
- name: useless-break
|
||||
- name: var-declaration
|
||||
- name: var-naming
|
||||
- name: waitgroup-by-value
|
||||
|
||||
stylecheck:
|
||||
checks: ["all"]
|
||||
|
||||
staticcheck:
|
||||
checks: ["all"]
|
||||
|
||||
unparam:
|
||||
check-exported: true
|
||||
|
||||
nakedret:
|
||||
max-func-lines: 0
|
||||
|
||||
cyclop:
|
||||
max-complexity: 10
|
||||
|
||||
gocyclo:
|
||||
min-complexity: 10
|
||||
|
||||
gocognit:
|
||||
min-complexity: 15
|
||||
|
||||
nestif:
|
||||
min-complexity: 4
|
||||
|
||||
lll:
|
||||
line-length: 120
|
||||
|
||||
maintidx:
|
||||
under: 20
|
||||
|
||||
funlen:
|
||||
lines: 80
|
||||
statements: 50
|
||||
|
||||
gochecknoglobals:
|
||||
check-no-globals: true
|
||||
|
||||
goconst:
|
||||
min-len: 3
|
||||
min-occurrences: 3
|
||||
|
||||
dupl:
|
||||
threshold: 100
|
||||
|
||||
forbidigo:
|
||||
forbid:
|
||||
- ^print.*$
|
||||
- ^fmt\.Print.*$
|
||||
|
||||
tagliatelle:
|
||||
case:
|
||||
rules:
|
||||
json: snake
|
||||
yaml: snake
|
||||
xml: camel
|
||||
bson: camel
|
||||
avro: snake
|
||||
mapstructure: kebab
|
||||
|
||||
varnamelen:
|
||||
min-name-length: 2
|
||||
ignore-names:
|
||||
- err
|
||||
- i
|
||||
- j
|
||||
- k
|
||||
- v
|
||||
- id
|
||||
- ok
|
||||
- db
|
||||
- tx
|
||||
- wg
|
||||
- mu
|
||||
|
||||
ireturn:
|
||||
allow:
|
||||
- anon
|
||||
- error
|
||||
- empty
|
||||
- stdlib
|
||||
|
||||
wrapcheck:
|
||||
ignoreSigs:
|
||||
- .Errorf(
|
||||
- errors.New(
|
||||
- errors.Unwrap(
|
||||
- .Wrap(
|
||||
- .Wrapf(
|
||||
- .WithMessage(
|
||||
|
||||
issues:
|
||||
max-issues-per-linter: 0
|
||||
max-same-issues: 0
|
||||
exclude-use-default: false
|
||||
@@ -27,6 +27,8 @@ func main() {
|
||||
dataDir string
|
||||
duo bool
|
||||
dnsServer string
|
||||
socksProxyAddr string
|
||||
socksProxyPort int
|
||||
)
|
||||
|
||||
flag.StringVar(&mode, "mode", "", "Mode: srv or cnc")
|
||||
@@ -38,6 +40,8 @@ func main() {
|
||||
flag.StringVar(&dataDir, "data", "data", "Path to data directory")
|
||||
flag.BoolVar(&duo, "duo", false, "Use dual channels for 2x throughput")
|
||||
flag.StringVar(&dnsServer, "dns", "1.1.1.1:53", "DNS server (default: Cloudflare 1.1.1.1)")
|
||||
flag.StringVar(&socksProxyAddr, "socks-proxy", "", "SOCKS5 proxy address (server only)")
|
||||
flag.IntVar(&socksProxyPort, "socks-proxy-port", 1080, "SOCKS5 proxy port (server only)")
|
||||
flag.Parse()
|
||||
|
||||
if debug {
|
||||
@@ -85,7 +89,7 @@ func main() {
|
||||
go func() {
|
||||
switch mode {
|
||||
case "srv":
|
||||
errCh <- server.Run(ctx, roomURL, keyHex, duo, dnsServer)
|
||||
errCh <- server.Run(ctx, roomURL, keyHex, duo, dnsServer, socksProxyAddr, socksProxyPort)
|
||||
case "cnc":
|
||||
errCh <- client.Run(ctx, roomURL, keyHex, socksPort, duo, "", "")
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/fish
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
python -m venv venv
|
||||
|
||||
source venv/bin/activate.fish
|
||||
source venv/bin/activate
|
||||
|
||||
pip install -r requirements.txt
|
||||
1185
doc/YTWA.md
1185
doc/YTWA.md
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"sync"
|
||||
@@ -21,18 +22,20 @@ import (
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
peers []*telemost.Peer
|
||||
cipher *crypto.Cipher
|
||||
mux *mux.Multiplexer
|
||||
connections map[uint16]net.Conn
|
||||
connMu sync.RWMutex
|
||||
streamPumps map[uint16]net.Conn
|
||||
pumpMu sync.Mutex
|
||||
peerIdx atomic.Uint32
|
||||
wg sync.WaitGroup
|
||||
dnsServer string
|
||||
dnsCache sync.Map
|
||||
resolver *net.Resolver
|
||||
peers []*telemost.Peer
|
||||
cipher *crypto.Cipher
|
||||
mux *mux.Multiplexer
|
||||
connections map[uint16]net.Conn
|
||||
connMu sync.RWMutex
|
||||
streamPumps map[uint16]net.Conn
|
||||
pumpMu sync.Mutex
|
||||
peerIdx atomic.Uint32
|
||||
wg sync.WaitGroup
|
||||
dnsServer string
|
||||
dnsCache sync.Map
|
||||
resolver *net.Resolver
|
||||
socksProxyAddr string
|
||||
socksProxyPort int
|
||||
}
|
||||
|
||||
type ConnectRequest struct {
|
||||
@@ -41,10 +44,9 @@ type ConnectRequest struct {
|
||||
Port int `json:"port"`
|
||||
}
|
||||
|
||||
func Run(ctx context.Context, roomURL, keyHex string, duo bool, dnsServer string) error {
|
||||
func Run(ctx context.Context, roomURL, keyHex string, duo bool, dnsServer, socksProxyAddr string, socksProxyPort int) error {
|
||||
runCtx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
var key []byte
|
||||
var err error
|
||||
|
||||
@@ -75,11 +77,13 @@ func Run(ctx context.Context, roomURL, keyHex string, duo bool, dnsServer string
|
||||
}
|
||||
|
||||
s := &Server{
|
||||
cipher: cipher,
|
||||
connections: make(map[uint16]net.Conn),
|
||||
streamPumps: make(map[uint16]net.Conn),
|
||||
peers: make([]*telemost.Peer, 0),
|
||||
dnsServer: dnsServer,
|
||||
cipher: cipher,
|
||||
connections: make(map[uint16]net.Conn),
|
||||
streamPumps: make(map[uint16]net.Conn),
|
||||
peers: make([]*telemost.Peer, 0),
|
||||
dnsServer: dnsServer,
|
||||
socksProxyAddr: socksProxyAddr,
|
||||
socksProxyPort: socksProxyPort,
|
||||
}
|
||||
|
||||
if dnsServer == "" {
|
||||
@@ -189,6 +193,39 @@ func Run(ctx context.Context, roomURL, keyHex string, duo bool, dnsServer string
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Server) socks5Connect(conn net.Conn, targetAddr string, targetPort int) error {
|
||||
if _, err := conn.Write([]byte{5, 1, 0}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp := make([]byte, 2)
|
||||
if _, err := io.ReadFull(conn, resp); err != nil {
|
||||
return err
|
||||
}
|
||||
if resp[0] != 5 || resp[1] != 0 {
|
||||
return fmt.Errorf("SOCKS5 auth failed")
|
||||
}
|
||||
|
||||
req := []byte{5, 1, 0, 3}
|
||||
req = append(req, byte(len(targetAddr)))
|
||||
req = append(req, []byte(targetAddr)...)
|
||||
req = append(req, byte(targetPort>>8), byte(targetPort))
|
||||
|
||||
if _, err := conn.Write(req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp = make([]byte, 10)
|
||||
if _, err := io.ReadFull(conn, resp); err != nil {
|
||||
return err
|
||||
}
|
||||
if resp[0] != 5 || resp[1] != 0 {
|
||||
return fmt.Errorf("SOCKS5 connect failed: %d", resp[1])
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) onData(data []byte) {
|
||||
plaintext, err := s.cipher.Decrypt(data)
|
||||
if err != nil {
|
||||
@@ -246,7 +283,6 @@ func (s *Server) run(ctx context.Context) error {
|
||||
|
||||
case <-ticker.C:
|
||||
}
|
||||
|
||||
sids := s.mux.GetStreams()
|
||||
|
||||
for _, sid := range sids {
|
||||
@@ -337,14 +373,32 @@ func (s *Server) handleConnect(ctx context.Context, sid uint16, req ConnectReque
|
||||
s.connMu.Unlock()
|
||||
|
||||
dialStart := time.Now()
|
||||
var conn net.Conn
|
||||
var err error
|
||||
|
||||
dialer := &net.Dialer{
|
||||
Timeout: 10 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
Resolver: s.resolver,
|
||||
if s.socksProxyAddr == "" {
|
||||
dialer := &net.Dialer{
|
||||
Timeout: 10 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
Resolver: s.resolver,
|
||||
}
|
||||
conn, err = dialer.Dial("tcp4", addr)
|
||||
logger.Verbose("TCP dial took %v for sid=%d (direct)", time.Since(dialStart), sid)
|
||||
} else {
|
||||
proxyAddr := fmt.Sprintf("%s:%d", s.socksProxyAddr, s.socksProxyPort)
|
||||
dialer := &net.Dialer{
|
||||
Timeout: 10 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}
|
||||
conn, err = dialer.Dial("tcp4", proxyAddr)
|
||||
if err == nil {
|
||||
if err := s.socks5Connect(conn, req.Addr, req.Port); err != nil {
|
||||
conn.Close()
|
||||
err = fmt.Errorf("SOCKS5 connect failed: %v", err)
|
||||
}
|
||||
}
|
||||
logger.Verbose("SOCKS5 proxy dial took %v for sid=%d", time.Since(dialStart), sid)
|
||||
}
|
||||
|
||||
conn, err := dialer.Dial("tcp4", addr)
|
||||
dialElapsed := time.Since(dialStart)
|
||||
|
||||
if err != nil {
|
||||
@@ -354,7 +408,6 @@ func (s *Server) handleConnect(ctx context.Context, sid uint16, req ConnectReque
|
||||
}
|
||||
|
||||
logger.Verbose("TCP dial took %v for sid=%d", dialElapsed, sid)
|
||||
|
||||
s.connMu.Lock()
|
||||
s.connections[sid] = conn
|
||||
s.connMu.Unlock()
|
||||
|
||||
13
readme.md
13
readme.md
@@ -28,10 +28,18 @@ or wait for the release or at least a beta
|
||||
|
||||
```bash
|
||||
# server ( podman, pre configured, easy )
|
||||
./srv.sh
|
||||
./script/srv.sh
|
||||
|
||||
# client ( podman, pre configured, easy
|
||||
./cnc.sh
|
||||
./script/cnc.sh
|
||||
|
||||
|
||||
# Also there's a client UI version (currently in beta)
|
||||
./script/ui.sh
|
||||
|
||||
# And then
|
||||
./build/olcrtc-ui
|
||||
|
||||
|
||||
# or native ( no podman ) linux
|
||||
GOOS=linux GOARCH=amd64 go build ./cmd/olcrtc
|
||||
@@ -49,7 +57,6 @@ GOOS=windows GOARCH=amd64 go build ./cmd/olcrtc
|
||||
|
||||
---
|
||||
|
||||
### Contact
|
||||
|
||||
Telegram: [zarazaex](https://t.me/zarazaexe)
|
||||
<br>
|
||||
|
||||
145
script/srv.sh
Executable file
145
script/srv.sh
Executable file
@@ -0,0 +1,145 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "ЕСЛИ У ВАС ЕСТЬ ПРОБЛЕМЫ - Я В КУРСЕ, ПРОЕКТ В БЕТЕ, ПО ПРОБЛЕМАМ В ЧАТ t.me/openlibrecommunity ИЛИ ВООБЩЕ НЕКУДА, ЖДИТЕ РЕЛИЗА"
|
||||
|
||||
set -e
|
||||
|
||||
CONTAINER_NAME="olcrtc-server"
|
||||
IMAGE_NAME="docker.io/library/golang:1.26-alpine"
|
||||
REPO_URL="https://github.com/openlibrecommunity/olcrtc.git"
|
||||
WORK_DIR="/tmp/olcrtc-deploy"
|
||||
|
||||
echo "=== OlcRTC Server Deployment Script ==="
|
||||
echo ""
|
||||
|
||||
if ! command -v podman &> /dev/null; then
|
||||
echo "[!] Installing Podman..."
|
||||
|
||||
if command -v apt &> /dev/null; then
|
||||
echo "[*] Detected apt (Debian/Ubuntu)"
|
||||
sudo apt update
|
||||
sudo apt install -y podman
|
||||
elif command -v dnf &> /dev/null; then
|
||||
echo "[*] Detected dnf (Fedora/RHEL)"
|
||||
sudo dnf install -y podman
|
||||
elif command -v yum &> /dev/null; then
|
||||
echo "[*] Detected yum (CentOS/RHEL)"
|
||||
sudo yum install -y podman
|
||||
elif command -v pacman &> /dev/null; then
|
||||
echo "[*] Detected pacman (Arch)"
|
||||
sudo pacman -Sy --noconfirm podman
|
||||
else
|
||||
echo "[X] Unsupported package manager. Install podman manually."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "[+] Using Podman"
|
||||
echo ""
|
||||
read -p "Enter Telemost Room ID: " ROOM_ID
|
||||
|
||||
if [ -z "$ROOM_ID" ]; then
|
||||
echo "[X] Room ID cannot be empty"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
read -p "Use SOCKS5 proxy for egress? (y/N): " USE_PROXY
|
||||
|
||||
SOCKS_PROXY_ADDR=""
|
||||
SOCKS_PROXY_PORT=""
|
||||
|
||||
if [[ "$USE_PROXY" =~ ^[Yy]$ ]]; then
|
||||
read -p "Enter SOCKS5 proxy address [default: 127.0.0.1]: " PROXY_ADDR_INPUT
|
||||
SOCKS_PROXY_ADDR=${PROXY_ADDR_INPUT:-127.0.0.1}
|
||||
|
||||
read -p "Enter SOCKS5 proxy port [default: 1080]: " PROXY_PORT_INPUT
|
||||
SOCKS_PROXY_PORT=${PROXY_PORT_INPUT:-1080}
|
||||
|
||||
echo "[*] Will use SOCKS5 proxy: $SOCKS_PROXY_ADDR:$SOCKS_PROXY_PORT"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "[*] Stopping old instance..."
|
||||
podman stop $CONTAINER_NAME 2>/dev/null || true
|
||||
podman rm $CONTAINER_NAME 2>/dev/null || true
|
||||
|
||||
echo "[*] Cleaning workspace..."
|
||||
rm -rf $WORK_DIR
|
||||
mkdir -p $WORK_DIR
|
||||
|
||||
echo "[*] Cloning repository..."
|
||||
git clone --depth 1 $REPO_URL $WORK_DIR
|
||||
|
||||
echo "[*] Pulling Go image..."
|
||||
podman pull $IMAGE_NAME
|
||||
|
||||
echo "[*] Building OlcRTC..."
|
||||
podman run --rm \
|
||||
-v $WORK_DIR:/app:Z \
|
||||
-w /app \
|
||||
$IMAGE_NAME \
|
||||
sh -c "go mod tidy && go build -o olcrtc cmd/olcrtc/main.go"
|
||||
|
||||
if [ ! -f "$WORK_DIR/olcrtc" ]; then
|
||||
echo "[X] Build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
KEY_FILE="$HOME/.olcrtc_key"
|
||||
|
||||
if [ -f "$KEY_FILE" ]; then
|
||||
echo "[*] Loading existing encryption key..."
|
||||
KEY=$(cat "$KEY_FILE")
|
||||
else
|
||||
echo "[*] Generating new encryption key..."
|
||||
KEY=$(openssl rand -hex 32)
|
||||
echo "$KEY" > "$KEY_FILE"
|
||||
chmod 600 "$KEY_FILE"
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "NEW ENCRYPTION KEY (saved to $KEY_FILE):"
|
||||
echo "$KEY"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Build server command with optional proxy parameters
|
||||
SERVER_CMD="./olcrtc -mode srv -id \"$ROOM_ID\" -key \"$KEY\""
|
||||
|
||||
if [ ! -z "$SOCKS_PROXY_ADDR" ]; then
|
||||
SERVER_CMD="$SERVER_CMD -socks-proxy \"$SOCKS_PROXY_ADDR\" -socks-proxy-port $SOCKS_PROXY_PORT"
|
||||
fi
|
||||
|
||||
echo "[*] Starting OlcRTC server..."
|
||||
podman run -d \
|
||||
--name $CONTAINER_NAME \
|
||||
--restart unless-stopped \
|
||||
-v $WORK_DIR:/app:Z \
|
||||
-w /app \
|
||||
$IMAGE_NAME \
|
||||
sh -c "$SERVER_CMD"
|
||||
|
||||
sleep 2
|
||||
|
||||
echo ""
|
||||
echo "[+] Server started successfully!"
|
||||
echo ""
|
||||
echo "Container name: $CONTAINER_NAME"
|
||||
echo "Room ID: $ROOM_ID"
|
||||
echo "Encryption key: $KEY"
|
||||
|
||||
if [ ! -z "$SOCKS_PROXY_ADDR" ]; then
|
||||
echo "SOCKS5 proxy: $SOCKS_PROXY_ADDR:$SOCKS_PROXY_PORT"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "View logs:"
|
||||
echo " podman logs -f $CONTAINER_NAME"
|
||||
echo ""
|
||||
echo "Stop server:"
|
||||
echo " podman stop $CONTAINER_NAME"
|
||||
echo ""
|
||||
echo "Client command:"
|
||||
echo " ./olcrtc -mode cnc -id \"$ROOM_ID\" -key \"$KEY\" -socks-port 1080"
|
||||
echo ""
|
||||
29
script/ui.sh
Executable file
29
script/ui.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
BUILD_DIR="$PROJECT_ROOT/build"
|
||||
|
||||
mkdir -p "$BUILD_DIR"
|
||||
|
||||
echo "=== Building OlcRTC ==="
|
||||
echo ""
|
||||
|
||||
echo "[1/2] Building olcrtc binary..."
|
||||
cd "$PROJECT_ROOT"
|
||||
go build -o "$BUILD_DIR/olcrtc" ./cmd/olcrtc/main.go
|
||||
echo "✓ olcrtc binary built: $BUILD_DIR/olcrtc"
|
||||
|
||||
echo ""
|
||||
echo "[2/2] Building UI binary..."
|
||||
cd "$PROJECT_ROOT/ui"
|
||||
go build -o "$BUILD_DIR/olcrtc-ui" .
|
||||
echo "✓ UI binary built: $BUILD_DIR/olcrtc-ui"
|
||||
|
||||
echo ""
|
||||
echo "=== Build Complete ==="
|
||||
echo "Binaries ready:"
|
||||
echo " - $BUILD_DIR/olcrtc"
|
||||
echo " - $BUILD_DIR/olcrtc-ui"
|
||||
118
srv.sh
118
srv.sh
@@ -1,118 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
echo "ЕСЛИ У ВАС ЕСТЬ ПРОБЛЕМЫ - Я В КУРСЕ, ПРОЕКТ В БЕТЕ, ПО ПРОБЛЕМАМ В ЧАТ t.me/openlibrecommunity ИЛИ ВООБЩЕ НЕКУДА, ЖДИТЕ РЕЛИЗА"
|
||||
|
||||
set -e
|
||||
|
||||
CONTAINER_NAME="olcrtc-server"
|
||||
IMAGE_NAME="docker.io/library/golang:1.26-alpine"
|
||||
REPO_URL="https://github.com/openlibrecommunity/olcrtc.git"
|
||||
WORK_DIR="/tmp/olcrtc-deploy"
|
||||
|
||||
echo "=== OlcRTC Server Deployment Script ==="
|
||||
echo ""
|
||||
|
||||
if ! command -v podman &> /dev/null; then
|
||||
echo "[!] Installing Podman..."
|
||||
|
||||
if command -v apt &> /dev/null; then
|
||||
echo "[*] Detected apt (Debian/Ubuntu)"
|
||||
sudo apt update
|
||||
sudo apt install -y podman
|
||||
elif command -v dnf &> /dev/null; then
|
||||
echo "[*] Detected dnf (Fedora/RHEL)"
|
||||
sudo dnf install -y podman
|
||||
elif command -v yum &> /dev/null; then
|
||||
echo "[*] Detected yum (CentOS/RHEL)"
|
||||
sudo yum install -y podman
|
||||
elif command -v pacman &> /dev/null; then
|
||||
echo "[*] Detected pacman (Arch)"
|
||||
sudo pacman -Sy --noconfirm podman
|
||||
else
|
||||
echo "[X] Unsupported package manager. Install podman manually."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "[+] Using Podman"
|
||||
echo ""
|
||||
read -p "Enter Telemost Room ID: " ROOM_ID
|
||||
|
||||
if [ -z "$ROOM_ID" ]; then
|
||||
echo "[X] Room ID cannot be empty"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "[*] Stopping old instance..."
|
||||
podman stop $CONTAINER_NAME 2>/dev/null || true
|
||||
podman rm $CONTAINER_NAME 2>/dev/null || true
|
||||
|
||||
echo "[*] Cleaning workspace..."
|
||||
rm -rf $WORK_DIR
|
||||
mkdir -p $WORK_DIR
|
||||
|
||||
echo "[*] Cloning repository..."
|
||||
git clone --depth 1 $REPO_URL $WORK_DIR
|
||||
|
||||
echo "[*] Pulling Go image..."
|
||||
podman pull $IMAGE_NAME
|
||||
|
||||
echo "[*] Building OlcRTC..."
|
||||
podman run --rm \
|
||||
-v $WORK_DIR:/app:Z \
|
||||
-w /app \
|
||||
$IMAGE_NAME \
|
||||
sh -c "go mod tidy && go build -o olcrtc cmd/olcrtc/main.go"
|
||||
|
||||
if [ ! -f "$WORK_DIR/olcrtc" ]; then
|
||||
echo "[X] Build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
KEY_FILE="$HOME/.olcrtc_key"
|
||||
|
||||
if [ -f "$KEY_FILE" ]; then
|
||||
echo "[*] Loading existing encryption key..."
|
||||
KEY=$(cat "$KEY_FILE")
|
||||
else
|
||||
echo "[*] Generating new encryption key..."
|
||||
KEY=$(openssl rand -hex 32)
|
||||
echo "$KEY" > "$KEY_FILE"
|
||||
chmod 600 "$KEY_FILE"
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "NEW ENCRYPTION KEY (saved to $KEY_FILE):"
|
||||
echo "$KEY"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "[*] Starting OlcRTC server..."
|
||||
podman run -d \
|
||||
--name $CONTAINER_NAME \
|
||||
--restart unless-stopped \
|
||||
-v $WORK_DIR:/app:Z \
|
||||
-w /app \
|
||||
$IMAGE_NAME \
|
||||
./olcrtc -mode srv -id "$ROOM_ID" -key "$KEY"
|
||||
|
||||
sleep 2
|
||||
|
||||
echo ""
|
||||
echo "[+] Server started successfully!"
|
||||
echo ""
|
||||
echo "Container name: $CONTAINER_NAME"
|
||||
echo "Room ID: $ROOM_ID"
|
||||
echo "Encryption key: $KEY"
|
||||
echo ""
|
||||
echo "View logs:"
|
||||
echo " podman logs -f $CONTAINER_NAME"
|
||||
echo ""
|
||||
echo "Stop server:"
|
||||
echo " podman stop $CONTAINER_NAME"
|
||||
echo ""
|
||||
echo "Client command:"
|
||||
echo " ./olcrtc -mode cnc -id \"$ROOM_ID\" -key \"$KEY\" -socks-port 1080"
|
||||
echo ""
|
||||
134
ui/config.go
Normal file
134
ui/config.go
Normal file
@@ -0,0 +1,134 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Os string
|
||||
DNS string `json:"dns"` // todo
|
||||
EncryptionKey string `json:"encryption_key"`
|
||||
SocksPort string `json:"socks_port"`
|
||||
ConferenceID string `json:"conference_id"`
|
||||
}
|
||||
|
||||
func isValidPort(portStr string) bool {
|
||||
portStr = strings.TrimSpace(portStr)
|
||||
if portStr == "" {
|
||||
return false
|
||||
}
|
||||
port, err := strconv.Atoi(portStr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return port > 0 && port <= 65535
|
||||
}
|
||||
|
||||
func isValidConferenceID(conferenceID string) bool {
|
||||
conferenceID = strings.TrimSpace(conferenceID)
|
||||
if conferenceID == "" {
|
||||
return false
|
||||
}
|
||||
matched, err := regexp.MatchString(`^\d+$`, conferenceID)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return matched
|
||||
}
|
||||
|
||||
func (p *Program) getConfigPath() string {
|
||||
dir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
log("WARNING: Could not get system config directory: %v", err)
|
||||
return "config.json"
|
||||
}
|
||||
configDir := filepath.Join(dir, "olcrtc")
|
||||
if err := os.MkdirAll(configDir, 0755); err != nil {
|
||||
log("WARNING: Could not create config directory: %v", err)
|
||||
}
|
||||
return filepath.Join(configDir, "config.json")
|
||||
|
||||
}
|
||||
|
||||
func (p *Program) loadConfig() *Config {
|
||||
configPath := p.getConfigPath()
|
||||
log("Loading config from: %s", configPath)
|
||||
// default values
|
||||
cfg := &Config{
|
||||
DNS: "1.1.1.1",
|
||||
EncryptionKey: "",
|
||||
SocksPort: "1080",
|
||||
ConferenceID: "",
|
||||
}
|
||||
data, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
log("Config file not found. Using default configuration.")
|
||||
} else {
|
||||
log("WARNING: Could not read config file: %v", err)
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
if err := json.Unmarshal(data, cfg); err != nil {
|
||||
log("WARNING: Could not parse config file: %v", err)
|
||||
return cfg
|
||||
}
|
||||
cfg.ConferenceID = strings.ReplaceAll(cfg.ConferenceID, " ", "")
|
||||
if !isValidConferenceID(cfg.ConferenceID) {
|
||||
log("WARNING: Invalid conference ID in config (must be numbers only)")
|
||||
cfg.ConferenceID = ""
|
||||
}
|
||||
if !isValidPort(cfg.SocksPort) {
|
||||
log("WARNING: Invalid port in config, using default: 1080")
|
||||
cfg.SocksPort = "1080"
|
||||
}
|
||||
log("Config loaded successfully")
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (p *Program) saveConfig(dns, encryptionKey, socksPort, conferenceID string) {
|
||||
log("Saving configuration...")
|
||||
|
||||
conferenceID = strings.ReplaceAll(conferenceID, " ", "")
|
||||
|
||||
if !isValidPort(socksPort) {
|
||||
log("ERROR: Invalid port: %s", socksPort)
|
||||
p.showError(fmt.Errorf("invalid port: must be between 1 and 65535"))
|
||||
return
|
||||
}
|
||||
|
||||
if !isValidConferenceID(conferenceID) {
|
||||
log("ERROR: Invalid conference ID: %s", conferenceID)
|
||||
p.showError(fmt.Errorf("invalid conference ID: must contain only numbers"))
|
||||
return
|
||||
}
|
||||
|
||||
p.Config = &Config{
|
||||
DNS: dns,
|
||||
EncryptionKey: encryptionKey,
|
||||
SocksPort: socksPort,
|
||||
ConferenceID: conferenceID,
|
||||
}
|
||||
|
||||
configPath := p.getConfigPath()
|
||||
data, err := json.MarshalIndent(p.Config, "", " ")
|
||||
if err != nil {
|
||||
log("ERROR: Could not marshal config: %v", err)
|
||||
p.showError(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := os.WriteFile(configPath, data, 0644); err != nil {
|
||||
log("ERROR: Could not write config file: %v", err)
|
||||
p.showError(err)
|
||||
return
|
||||
}
|
||||
|
||||
log("Configuration saved to: %s", configPath)
|
||||
}
|
||||
40
ui/go.mod
Normal file
40
ui/go.mod
Normal file
@@ -0,0 +1,40 @@
|
||||
module github.com/openlibrecommunity/olcrtc/ui
|
||||
|
||||
go 1.26.1
|
||||
|
||||
require fyne.io/fyne/v2 v2.7.3
|
||||
|
||||
require (
|
||||
fyne.io/systray v1.12.0 // indirect
|
||||
github.com/BurntSushi/toml v1.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fredbi/uri v1.1.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/fyne-io/gl-js v0.2.0 // indirect
|
||||
github.com/fyne-io/glfw-js v0.3.0 // indirect
|
||||
github.com/fyne-io/image v0.1.1 // indirect
|
||||
github.com/fyne-io/oksvg v0.2.0 // indirect
|
||||
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 // indirect
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a // indirect
|
||||
github.com/go-text/render v0.2.0 // indirect
|
||||
github.com/go-text/typesetting v0.3.3 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/hack-pad/go-indexeddb v0.3.2 // indirect
|
||||
github.com/hack-pad/safejs v0.1.0 // indirect
|
||||
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade // indirect
|
||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/nicksnyder/go-i18n/v2 v2.5.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/rymdport/portal v0.4.2 // indirect
|
||||
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
|
||||
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
|
||||
github.com/stretchr/testify v1.11.1 // indirect
|
||||
github.com/yuin/goldmark v1.7.8 // indirect
|
||||
golang.org/x/image v0.24.0 // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
80
ui/go.sum
Normal file
80
ui/go.sum
Normal file
@@ -0,0 +1,80 @@
|
||||
fyne.io/fyne/v2 v2.7.3 h1:xBT/iYbdnNHONWO38fZMBrVBiJG8rV/Jypmy4tVfRWE=
|
||||
fyne.io/fyne/v2 v2.7.3/go.mod h1:gu+dlIcZWSzKZmnrY8Fbnj2Hirabv2ek+AKsfQ2bBlw=
|
||||
fyne.io/systray v1.12.0 h1:CA1Kk0e2zwFlxtc02L3QFSiIbxJ/P0n582YrZHT7aTM=
|
||||
fyne.io/systray v1.12.0/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
|
||||
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
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/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
||||
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
|
||||
github.com/fredbi/uri v1.1.1 h1:xZHJC08GZNIUhbP5ImTHnt5Ya0T8FI2VAwI/37kh2Ko=
|
||||
github.com/fredbi/uri v1.1.1/go.mod h1:4+DZQ5zBjEwQCDmXW5JdIjz0PUA+yJbvtBv+u+adr5o=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/fyne-io/gl-js v0.2.0 h1:+EXMLVEa18EfkXBVKhifYB6OGs3HwKO3lUElA0LlAjs=
|
||||
github.com/fyne-io/gl-js v0.2.0/go.mod h1:ZcepK8vmOYLu96JoxbCKJy2ybr+g1pTnaBDdl7c3ajI=
|
||||
github.com/fyne-io/glfw-js v0.3.0 h1:d8k2+Y7l+zy2pc7wlGRyPfTgZoqDf3AI4G+2zOWhWUk=
|
||||
github.com/fyne-io/glfw-js v0.3.0/go.mod h1:Ri6te7rdZtBgBpxLW19uBpp3Dl6K9K/bRaYdJ22G8Jk=
|
||||
github.com/fyne-io/image v0.1.1 h1:WH0z4H7qfvNUw5l4p3bC1q70sa5+YWVt6HCj7y4VNyA=
|
||||
github.com/fyne-io/image v0.1.1/go.mod h1:xrfYBh6yspc+KjkgdZU/ifUC9sPA5Iv7WYUBzQKK7JM=
|
||||
github.com/fyne-io/oksvg v0.2.0 h1:mxcGU2dx6nwjJsSA9PCYZDuoAcsZ/OuJlvg/Q9Njfo8=
|
||||
github.com/fyne-io/oksvg v0.2.0/go.mod h1:dJ9oEkPiWhnTFNCmRgEze+YNprJF7YRbpjgpWS4kzoI=
|
||||
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 h1:5BVwOaUSBTlVZowGO6VZGw2H/zl9nrd3eCZfYV+NfQA=
|
||||
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a h1:vxnBhFDDT+xzxf1jTJKMKZw3H0swfWk9RpWbBbDK5+0=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-text/render v0.2.0 h1:LBYoTmp5jYiJ4NPqDc2pz17MLmA3wHw1dZSVGcOdeAc=
|
||||
github.com/go-text/render v0.2.0/go.mod h1:CkiqfukRGKJA5vZZISkjSYrcdtgKQWRa2HIzvwNN5SU=
|
||||
github.com/go-text/typesetting v0.3.3 h1:ihGNJU9KzdK2QRDy1Bm7FT5RFQoYb+3n3EIhI/4eaQc=
|
||||
github.com/go-text/typesetting v0.3.3/go.mod h1:vIRUT25mLQaSh4C8H/lIsKppQz/Gdb8Pu/tNwpi52ts=
|
||||
github.com/go-text/typesetting-utils v0.0.0-20250618110550-c820a94c77b8 h1:4KCscI9qYWMGTuz6BpJtbUSRzcBrUSSE0ENMJbNSrFs=
|
||||
github.com/go-text/typesetting-utils v0.0.0-20250618110550-c820a94c77b8/go.mod h1:3/62I4La/HBRX9TcTpBj4eipLiwzf+vhI+7whTc9V7o=
|
||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y=
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
|
||||
github.com/hack-pad/go-indexeddb v0.3.2 h1:DTqeJJYc1usa45Q5r52t01KhvlSN02+Oq+tQbSBI91A=
|
||||
github.com/hack-pad/go-indexeddb v0.3.2/go.mod h1:QvfTevpDVlkfomY498LhstjwbPW6QC4VC/lxYb0Kom0=
|
||||
github.com/hack-pad/safejs v0.1.0 h1:qPS6vjreAqh2amUqj4WNG1zIw7qlRQJ9K10eDKMCnE8=
|
||||
github.com/hack-pad/safejs v0.1.0/go.mod h1:HdS+bKF1NrE72VoXZeWzxFOVQVUSqZJAG0xNCnb+Tio=
|
||||
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade h1:FmusiCI1wHw+XQbvL9M+1r/C3SPqKrmBaIOYwVfQoDE=
|
||||
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade/go.mod h1:ZDXo8KHryOWSIqnsb/CiDq7hQUYryCgdVnxbj8tDG7o=
|
||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 h1:YLvr1eE6cdCqjOe972w/cYF+FjW34v27+9Vo5106B4M=
|
||||
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25/go.mod h1:kLgvv7o6UM+0QSf0QjAse3wReFDsb9qbZJdfexWlrQw=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.5.1 h1:IxtPxYsR9Gp60cGXjfuR/llTqV8aYMsC472zD0D1vHk=
|
||||
github.com/nicksnyder/go-i18n/v2 v2.5.1/go.mod h1:DrhgsSDZxoAfvVrBVLXoxZn/pN5TXqaDbq7ju94viiQ=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA=
|
||||
github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo=
|
||||
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/rymdport/portal v0.4.2 h1:7jKRSemwlTyVHHrTGgQg7gmNPJs88xkbKcIL3NlcmSU=
|
||||
github.com/rymdport/portal v0.4.2/go.mod h1:kFF4jslnJ8pD5uCi17brj/ODlfIidOxlgUDTO5ncnC4=
|
||||
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c h1:km8GpoQut05eY3GiYWEedbTT0qnSxrCjsVbb7yKY1KE=
|
||||
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c/go.mod h1:cNQ3dwVJtS5Hmnjxy6AgTPd0Inb3pW05ftPSX7NZO7Q=
|
||||
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef h1:Ch6Q+AZUxDBCVqdkI8FSpFyZDtCVBc2VmejdNrm5rRQ=
|
||||
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
|
||||
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
|
||||
golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
|
||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
23
ui/logger.go
Normal file
23
ui/logger.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
var currentProgram *Program
|
||||
|
||||
func log(msg string, args ...interface{}) {
|
||||
var formattedMsg string
|
||||
if len(args) > 0 {
|
||||
formattedMsg = fmt.Sprintf(msg, args...)
|
||||
fmt.Println(formattedMsg)
|
||||
} else {
|
||||
formattedMsg = msg
|
||||
fmt.Println(msg)
|
||||
}
|
||||
|
||||
if currentProgram != nil && currentProgram.LogsChannel != nil {
|
||||
select {
|
||||
case currentProgram.LogsChannel <- formattedMsg:
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
129
ui/main.go
Normal file
129
ui/main.go
Normal file
@@ -0,0 +1,129 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"image/color"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
type Program struct {
|
||||
App fyne.App
|
||||
ParentWindow fyne.Window
|
||||
RunString string
|
||||
RunCheck *widget.Check
|
||||
Config *Config
|
||||
Cmd *exec.Cmd
|
||||
CmdMu sync.Mutex
|
||||
LogsArea *widget.RichText
|
||||
LogsText *widget.Label
|
||||
LogsChannel chan string
|
||||
LogsContent string
|
||||
LogsMu sync.Mutex
|
||||
}
|
||||
|
||||
func main() {
|
||||
log("Starting application...")
|
||||
program := NewProgram()
|
||||
program.Run()
|
||||
}
|
||||
|
||||
func NewProgram() *Program {
|
||||
log("Initializing program...")
|
||||
uOs := runtime.GOOS
|
||||
log("RUNTIME: Detected OS - %v", uOs)
|
||||
p := &Program{
|
||||
App: app.New(),
|
||||
LogsChannel: make(chan string, 100),
|
||||
}
|
||||
currentProgram = p
|
||||
cfg := p.loadConfig()
|
||||
cfg.Os = uOs
|
||||
p.Config = cfg
|
||||
p.buildRunString(cfg.ConferenceID, cfg.EncryptionKey, cfg.SocksPort, cfg.DNS)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *Program) Run() {
|
||||
log("Creating main window...")
|
||||
w := p.App.NewWindow("OlcRTC")
|
||||
w.CenterOnScreen()
|
||||
w.Resize(fyne.NewSize(1280, 700))
|
||||
w.SetOnClosed(p.olcrtcStop)
|
||||
p.ParentWindow = w
|
||||
|
||||
settingsBtn := widget.NewButtonWithIcon("Settings", theme.SettingsIcon(), func() {
|
||||
log("Settings button clicked")
|
||||
p.settingsWindow()
|
||||
})
|
||||
|
||||
p.RunCheck = widget.NewCheck("Run", func(b bool) {
|
||||
if b {
|
||||
log("Run enabled")
|
||||
p.olcrtcRun()
|
||||
} else {
|
||||
log("Run disabled")
|
||||
p.olcrtcStop()
|
||||
}
|
||||
})
|
||||
|
||||
// Create logs display area
|
||||
p.LogsText = widget.NewLabel("")
|
||||
p.LogsText.Wrapping = fyne.TextWrapWord
|
||||
logsScroll := container.NewScroll(p.LogsText)
|
||||
logsScroll.SetMinSize(fyne.NewSize(0, 300))
|
||||
|
||||
// Create styled logs box with darker background
|
||||
bgRect := canvas.NewRectangle(color.NRGBA{R: 40, G: 40, B: 40, A: 255})
|
||||
logsWithPadding := container.NewBorder(
|
||||
widget.NewLabel("Logs"),
|
||||
nil, nil, nil,
|
||||
logsScroll,
|
||||
)
|
||||
logsBox := container.NewStack(
|
||||
bgRect,
|
||||
container.NewBorder(
|
||||
nil, nil, nil, nil,
|
||||
logsWithPadding,
|
||||
),
|
||||
)
|
||||
|
||||
topBar := container.NewBorder(
|
||||
settingsBtn,
|
||||
p.RunCheck, nil, nil,
|
||||
)
|
||||
|
||||
mainContent := container.NewVBox(
|
||||
topBar,
|
||||
logsBox,
|
||||
)
|
||||
|
||||
w.SetContent(mainContent)
|
||||
|
||||
go p.listenLogs()
|
||||
|
||||
log("Window created and running...")
|
||||
w.ShowAndRun()
|
||||
}
|
||||
|
||||
func (p *Program) listenLogs() {
|
||||
for logMsg := range p.LogsChannel {
|
||||
fyne.Do(func() {
|
||||
if p.LogsText != nil {
|
||||
p.LogsMu.Lock()
|
||||
p.LogsContent += logMsg + "\n"
|
||||
logsToDisplay := p.LogsContent
|
||||
p.LogsMu.Unlock()
|
||||
p.LogsText.SetText(logsToDisplay)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
150
ui/process.go
Normal file
150
ui/process.go
Normal file
@@ -0,0 +1,150 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
func pipeOutput(reader io.ReadCloser, prefix string) {
|
||||
defer reader.Close()
|
||||
scanner := bufio.NewScanner(reader)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if prefix != "" {
|
||||
log("olcrtc %s: %s", prefix, line)
|
||||
} else {
|
||||
log("olcrtc: %s", line)
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
log("ERROR: Failed to read %s: %v", prefix, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Program) olcrtcRun() {
|
||||
log("%s - Starting olcrtc process...", time.Now().Format("2006-01-02 15:04:05"))
|
||||
if p.RunString == "" {
|
||||
log("ERROR: Run string is empty. Please configure settings first.")
|
||||
p.showError(fmt.Errorf("run string is empty - please configure settings"))
|
||||
p.MarkUncheck()
|
||||
return
|
||||
}
|
||||
|
||||
var cmd *exec.Cmd
|
||||
if p.Config.Os == "windows" {
|
||||
cmd = exec.Command("cmd.exe", "/C", p.RunString)
|
||||
} else {
|
||||
cmd = exec.Command("sh", "-c", p.RunString)
|
||||
}
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
log("ERROR: Failed to create stdout pipe: %v", err)
|
||||
p.showError(err)
|
||||
p.MarkUncheck()
|
||||
return
|
||||
}
|
||||
|
||||
stderr, err := cmd.StderrPipe()
|
||||
if err != nil {
|
||||
log("ERROR: Failed to create stderr pipe: %v", err)
|
||||
p.showError(err)
|
||||
p.MarkUncheck()
|
||||
return
|
||||
}
|
||||
|
||||
p.CmdMu.Lock()
|
||||
p.Cmd = cmd
|
||||
err = p.Cmd.Start()
|
||||
pid := 0
|
||||
if err == nil && p.Cmd.Process != nil {
|
||||
pid = p.Cmd.Process.Pid
|
||||
}
|
||||
p.CmdMu.Unlock()
|
||||
|
||||
if err != nil {
|
||||
log("ERROR: Failed to start olcrtc: %v", err)
|
||||
p.showError(err)
|
||||
p.CmdMu.Lock()
|
||||
p.Cmd = nil
|
||||
p.CmdMu.Unlock()
|
||||
p.MarkUncheck()
|
||||
} else {
|
||||
log("olcrtc process started (PID: %d)", pid)
|
||||
|
||||
go pipeOutput(stdout, "stdout")
|
||||
go pipeOutput(stderr, "stderr")
|
||||
|
||||
go func() {
|
||||
p.CmdMu.Lock()
|
||||
cmd := p.Cmd
|
||||
p.CmdMu.Unlock()
|
||||
|
||||
if cmd != nil {
|
||||
err = cmd.Wait()
|
||||
if err != nil {
|
||||
log("olcrtc process exited with error: %v", err)
|
||||
p.MarkUncheck()
|
||||
} else {
|
||||
log("olcrtc process exited successfully")
|
||||
}
|
||||
}
|
||||
|
||||
p.CmdMu.Lock()
|
||||
p.Cmd = nil
|
||||
p.CmdMu.Unlock()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Program) olcrtcStop() {
|
||||
log("%s - Stopping olcrtc process...", time.Now().Format("2006-01-02 15:04:05"))
|
||||
|
||||
p.CmdMu.Lock()
|
||||
cmd := p.Cmd
|
||||
p.CmdMu.Unlock()
|
||||
|
||||
if cmd == nil || cmd.Process == nil {
|
||||
log("WARNING: No active olcrtc process to stop")
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
if p.Config.Os == "windows" {
|
||||
err = cmd.Process.Kill()
|
||||
} else {
|
||||
err = cmd.Process.Signal(os.Interrupt)
|
||||
}
|
||||
if err != nil {
|
||||
log("ERROR: Failed to signal olcrtc: %v", err)
|
||||
p.showError(err)
|
||||
return
|
||||
}
|
||||
|
||||
log("olcrtc process termination signal sent (PID: %d)", cmd.Process.Pid)
|
||||
|
||||
done := make(chan error, 1)
|
||||
go func() {
|
||||
done <- cmd.Wait()
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-time.After(5 * time.Second):
|
||||
log("WARNING: Process did not exit gracefully, forcing kill...")
|
||||
if err := cmd.Process.Kill(); err != nil {
|
||||
log("ERROR: Failed to kill olcrtc: %v", err)
|
||||
} else {
|
||||
log("olcrtc process forcefully killed (PID: %d)", cmd.Process.Pid)
|
||||
}
|
||||
case err := <-done:
|
||||
if err != nil {
|
||||
log("olcrtc process exited with error: %v", err)
|
||||
} else {
|
||||
log("olcrtc process exited gracefully")
|
||||
}
|
||||
}
|
||||
}
|
||||
84
ui/ui.go
Normal file
84
ui/ui.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
func (p *Program) settingsWindow() {
|
||||
log("Opening settings dialog...")
|
||||
|
||||
dns := widget.NewEntry()
|
||||
dns.SetPlaceHolder("1.1.1.1")
|
||||
if p.Config.DNS != "" {
|
||||
dns.SetText(p.Config.DNS)
|
||||
}
|
||||
|
||||
encrpKey := widget.NewEntry()
|
||||
if p.Config.EncryptionKey != "" {
|
||||
encrpKey.SetText(p.Config.EncryptionKey)
|
||||
}
|
||||
|
||||
socksPort := widget.NewEntry()
|
||||
socksPort.SetPlaceHolder("1080")
|
||||
if p.Config.SocksPort != "" {
|
||||
socksPort.SetText(p.Config.SocksPort)
|
||||
}
|
||||
|
||||
conferenceId := widget.NewEntry()
|
||||
if p.Config.ConferenceID != "" {
|
||||
conferenceId.SetText(p.Config.ConferenceID)
|
||||
}
|
||||
|
||||
applyBtn := widget.NewButtonWithIcon("Apply", theme.CheckButtonCheckedIcon(), func() {
|
||||
log("Applying settings...")
|
||||
p.buildRunString(conferenceId.Text, encrpKey.Text, socksPort.Text, dns.Text)
|
||||
p.saveConfig(dns.Text, encrpKey.Text, socksPort.Text, conferenceId.Text)
|
||||
})
|
||||
|
||||
content := container.NewVBox(
|
||||
widget.NewLabel("Custom DNS Server"),
|
||||
dns,
|
||||
widget.NewLabel("Encryption Key"),
|
||||
encrpKey,
|
||||
widget.NewLabel("Socks Port"),
|
||||
socksPort,
|
||||
widget.NewLabel("Conference ID"),
|
||||
conferenceId,
|
||||
applyBtn,
|
||||
)
|
||||
dialog.ShowCustom("Settings", "Close", content, p.ParentWindow)
|
||||
}
|
||||
|
||||
func (p *Program) buildRunString(conferenceId, encryptionKey, socksPort, dns string) {
|
||||
log("Building run string...")
|
||||
log(" Conference ID: %s", conferenceId)
|
||||
log(" Encryption Key: %s", encryptionKey)
|
||||
log(" Socks Port: %s", socksPort)
|
||||
log(" DNS Server: %s", dns)
|
||||
switch p.Config.Os {
|
||||
case "windows":
|
||||
p.RunString = fmt.Sprintf("olcrtc.exe -mode cnc -id \"%s\" -key \"%s\" -socks-port %s -dns %s", conferenceId, encryptionKey, socksPort, dns)
|
||||
case "linux", "darwin":
|
||||
p.RunString = fmt.Sprintf("./olcrtc -mode cnc -id \"%s\" -key \"%s\" -socks-port %s -dns %s", conferenceId, encryptionKey, socksPort, dns)
|
||||
default: // in case for freeBSD and etc
|
||||
p.RunString = fmt.Sprintf("olcrtc -mode cnc -id \"%s\" -key \"%s\" -socks-port %s -dns %s", conferenceId, encryptionKey, socksPort, dns)
|
||||
}
|
||||
log("Generated command: %s", p.RunString)
|
||||
}
|
||||
|
||||
func (p *Program) showError(err error) {
|
||||
dialog.ShowError(err, p.ParentWindow)
|
||||
}
|
||||
|
||||
// fyne.Do used here to execute function in the main context frame
|
||||
// we can just paste p.RunCheck.SetChecked(false) and that'll work. but if so
|
||||
// there'll be a bunch of warnings(thread safety)
|
||||
func (p *Program) MarkUncheck() {
|
||||
fyne.Do(func() { p.RunCheck.SetChecked(false) })
|
||||
}
|
||||
Reference in New Issue
Block a user