Spaces:
Paused
Paused
File size: 2,992 Bytes
f7b0db6 07da0f8 167887d 4e46096 f7b0db6 167887d 4e46096 f7b0db6 167887d f7b0db6 4e46096 07da0f8 f7b0db6 4e46096 f7b0db6 62d1865 f7b0db6 4e46096 f7b0db6 4e46096 f7b0db6 4e46096 f7b0db6 62d1865 167887d f7b0db6 167887d f7b0db6 167887d f7b0db6 167887d f7b0db6 01e6fee 4e46096 62d1865 f7b0db6 4e46096 f7b0db6 4e46096 f7b0db6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# --- START OF FILE Dockerfile ---
FROM golang:latest
# Обновление и зависимости
RUN apt-get update && apt-get install -y wget unzip git build-essential python3
# Настройка Android NDK
ENV ANDROID_NDK_HOME /opt/android-ndk
ENV ANDROID_NDK_VERSION r25c
RUN wget -q https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux.zip && \
unzip -q android-ndk-${ANDROID_NDK_VERSION}-linux.zip && \
mv android-ndk-${ANDROID_NDK_VERSION} /opt/android-ndk && \
rm android-ndk-${ANDROID_NDK_VERSION}-linux.zip
ENV PATH ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
WORKDIR /app
# Настройка Go
ENV GOTOOLCHAIN=auto
RUN go mod init vless-client
# Исправленный код main.go
RUN cat <<EOF > main.go
package main
import "C"
import (
"encoding/base64"
"strings"
"sync"
"github.com/xtls/xray-core/core"
"github.com/xtls/xray-core/infra/conf/serial"
_ "github.com/xtls/xray-core/main/distro/all"
)
var (
instance *core.Instance
mu sync.Mutex
)
//export StartCore
func StartCore(configContent *C.char) *C.char {
mu.Lock()
defer mu.Unlock()
if instance != nil {
return C.CString("Core already running")
}
configStr := C.GoString(configContent)
// 1. Декодируем JSON в структуру conf.Config
confConfig, err := serial.DecodeJSONConfig(strings.NewReader(configStr))
if err != nil {
return C.CString("Config parse error: " + err.Error())
}
// 2. !!! ВАЖНО !!! Конвертируем conf.Config в core.Config
coreConfig, err := confConfig.Build()
if err != nil {
return C.CString("Config build error: " + err.Error())
}
// 3. Создаем инстанс ядра
coreInstance, err := core.New(coreConfig)
if err != nil {
return C.CString("Core create error: " + err.Error())
}
if err := coreInstance.Start(); err != nil {
return C.CString("Core start error: " + err.Error())
}
instance = coreInstance
return C.CString("")
}
//export StopCore
func StopCore() {
mu.Lock()
defer mu.Unlock()
if instance != nil {
instance.Close()
instance = nil
}
}
//export Base64Decode
func Base64Decode(str *C.char) *C.char {
data := C.GoString(str)
if l := len(data) % 4; l > 0 {
data += strings.Repeat("=", 4-l)
}
decoded, err := base64.StdEncoding.DecodeString(data)
if err != nil {
decoded, err = base64.URLEncoding.DecodeString(data)
}
if err != nil {
return C.CString("")
}
return C.CString(string(decoded))
}
func main() {}
EOF
# Зависимости
RUN go get -u github.com/xtls/xray-core@latest
RUN go mod tidy
# Компиляция
RUN CGO_ENABLED=1 \
GOOS=android \
GOARCH=arm64 \
CC=aarch64-linux-android33-clang \
go build -buildmode=c-shared -o libvless.so main.go
# Выдача файла
RUN mkdir /output && mv libvless.so /output/
WORKDIR /output
CMD ["python3", "-m", "http.server", "7860"]
# --- END OF FILE Dockerfile --- |