-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
407 additions
and
767 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.git | ||
.gitignore | ||
.env* | ||
README.md | ||
Dockerfile | ||
docker-compose.yml | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
FROM golang:1.22.5-alpine AS builder | ||
# Install required system packages | ||
RUN apk update && \ | ||
apk upgrade && \ | ||
apk add --no-cache ca-certificates && \ | ||
update-ca-certificates | ||
# Install required packages and set up workspace in a single layer | ||
RUN apk add --no-cache ca-certificates && update-ca-certificates | ||
|
||
WORKDIR /build | ||
|
||
# Copy go mod and source files | ||
COPY go.mod go.sum ./ | ||
COPY *.go ./ | ||
|
||
# Download dependencies | ||
RUN go mod download | ||
# Copy all necessary files in a single layer | ||
COPY . . | ||
|
||
# Build the application | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o proxy-server . | ||
RUN go mod download && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o proxy-server ./cmd/main.go | ||
|
||
# Final stage | ||
# Final stage - minimal image | ||
FROM scratch | ||
WORKDIR /app | ||
COPY --from=builder /build/proxy-server . | ||
|
||
# Copy only the necessary files from builder | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /build/proxy-server . | ||
COPY --from=builder /build/proxies.conf ./proxies.conf | ||
COPY --from=builder /build/users.conf ./users.conf | ||
|
||
EXPOSE 1080 | ||
CMD ["./proxy-server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/armon/go-socks5" | ||
"go-proxy-rotator/internal/config" | ||
"go-proxy-rotator/internal/proxy_dialer" | ||
"go-proxy-rotator/internal/proxy_manager" | ||
"log" | ||
) | ||
|
||
func main() { | ||
// Load configuration | ||
cfg := config.NewConfig() | ||
|
||
// Load user credentials | ||
credentials, err := config.LoadUserCredentials(cfg.UsersFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Initialize proxy manager | ||
proxyManager := proxy_manager.NewManager(cfg.EnableEdgeMode) | ||
if err := proxyManager.LoadProxies(cfg.ProxiesFile); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Initialize proxy dialer | ||
dialer := proxy_dialer.NewProxyDialer(proxyManager) | ||
|
||
// Create SOCKS5 server configuration with authentication | ||
serverConfig := &socks5.Config{ | ||
Dial: dialer.Dial, | ||
Credentials: credentials, | ||
AuthMethods: []socks5.Authenticator{socks5.UserPassAuthenticator{ | ||
Credentials: credentials, | ||
}}, | ||
} | ||
|
||
server, err := socks5.New(serverConfig) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Printf("SOCKS5 server running on %s (Edge Mode: %v, Users: %d)\n", | ||
cfg.ListenAddr, | ||
cfg.EnableEdgeMode, | ||
len(credentials)) | ||
|
||
// Start server | ||
if err := server.ListenAndServe("tcp", cfg.ListenAddr); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
Oops, something went wrong.