mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-21 08:44:26 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
739a2dcd84 |
@@ -40,15 +40,21 @@ RUN echo '{}' >/tmp/usr/local/etc/xray/11_geodata.json
|
|||||||
RUN echo '{}' >/tmp/usr/local/etc/xray/12_env.json
|
RUN echo '{}' >/tmp/usr/local/etc/xray/12_env.json
|
||||||
RUN echo '{}' >/tmp/usr/local/etc/xray/99_version.json
|
RUN echo '{}' >/tmp/usr/local/etc/xray/99_version.json
|
||||||
|
|
||||||
|
# Create log files
|
||||||
|
RUN mkdir -p /tmp/var/log/xray && touch \
|
||||||
|
/tmp/var/log/xray/access.log \
|
||||||
|
/tmp/var/log/xray/error.log
|
||||||
|
|
||||||
# Build finally image
|
# Build finally image
|
||||||
FROM gcr.io/distroless/static:nonroot
|
FROM gcr.io/distroless/static:nonroot
|
||||||
|
|
||||||
COPY --from=build --chown=0:0 --chmod=755 /src/xray /usr/local/bin/xray
|
COPY --from=build --chown=0:0 --chmod=755 /src/xray /usr/local/bin/xray
|
||||||
COPY --from=build --chown=65532:65532 --chmod=755 /tmp/empty /usr/local/share/xray
|
COPY --from=build --chown=65532:65532 --chmod=755 /tmp/empty /usr/local/share/xray
|
||||||
COPY --from=build --chown=65532:65532 --chmod=644 /tmp/geodat/*.dat /usr/local/share/xray/
|
COPY --from=build --chown=65532:65532 --chmod=644 /tmp/geodat/*.dat /usr/local/share/xray/
|
||||||
COPY --from=build --chown=0:65532 --chmod=750 /tmp/empty /usr/local/etc/xray
|
COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /usr/local/etc/xray
|
||||||
COPY --from=build --chown=0:65532 --chmod=640 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/
|
COPY --from=build --chown=0:0 --chmod=644 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/
|
||||||
COPY --from=build --chown=65532:65532 --chmod=700 /tmp/empty /var/log/xray
|
COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /var/log/xray
|
||||||
|
COPY --from=build --chown=65532:65532 --chmod=600 /tmp/var/log/xray/*.log /var/log/xray/
|
||||||
|
|
||||||
VOLUME /usr/local/etc/xray
|
VOLUME /usr/local/etc/xray
|
||||||
VOLUME /var/log/xray
|
VOLUME /var/log/xray
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ RUN echo '{}' >/tmp/usr/local/etc/xray/11_geodata.json
|
|||||||
RUN echo '{}' >/tmp/usr/local/etc/xray/12_env.json
|
RUN echo '{}' >/tmp/usr/local/etc/xray/12_env.json
|
||||||
RUN echo '{}' >/tmp/usr/local/etc/xray/99_version.json
|
RUN echo '{}' >/tmp/usr/local/etc/xray/99_version.json
|
||||||
|
|
||||||
|
# Create log files
|
||||||
|
RUN mkdir -p /tmp/var/log/xray && touch \
|
||||||
|
/tmp/var/log/xray/access.log \
|
||||||
|
/tmp/var/log/xray/error.log
|
||||||
|
|
||||||
# Build finally image
|
# Build finally image
|
||||||
# Note on Distroless Base Image and Architecture Support:
|
# Note on Distroless Base Image and Architecture Support:
|
||||||
# - The official 'gcr.io/distroless/static' image provided by Google only supports a limited set of architectures for Linux:
|
# - The official 'gcr.io/distroless/static' image provided by Google only supports a limited set of architectures for Linux:
|
||||||
@@ -55,9 +60,10 @@ FROM --platform=linux/amd64 gcr.io/distroless/static:nonroot
|
|||||||
COPY --from=build --chown=0:0 --chmod=755 /src/xray /usr/local/bin/xray
|
COPY --from=build --chown=0:0 --chmod=755 /src/xray /usr/local/bin/xray
|
||||||
COPY --from=build --chown=65532:65532 --chmod=755 /tmp/empty /usr/local/share/xray
|
COPY --from=build --chown=65532:65532 --chmod=755 /tmp/empty /usr/local/share/xray
|
||||||
COPY --from=build --chown=65532:65532 --chmod=644 /tmp/geodat/*.dat /usr/local/share/xray/
|
COPY --from=build --chown=65532:65532 --chmod=644 /tmp/geodat/*.dat /usr/local/share/xray/
|
||||||
COPY --from=build --chown=0:65532 --chmod=750 /tmp/empty /usr/local/etc/xray
|
COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /usr/local/etc/xray
|
||||||
COPY --from=build --chown=0:65532 --chmod=640 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/
|
COPY --from=build --chown=0:0 --chmod=644 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/
|
||||||
COPY --from=build --chown=65532:65532 --chmod=700 /tmp/empty /var/log/xray
|
COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /var/log/xray
|
||||||
|
COPY --from=build --chown=65532:65532 --chmod=600 /tmp/var/log/xray/*.log /var/log/xray/
|
||||||
|
|
||||||
VOLUME /usr/local/etc/xray
|
VOLUME /usr/local/etc/xray
|
||||||
VOLUME /var/log/xray
|
VOLUME /var/log/xray
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package socks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/signal"
|
"github.com/xtls/xray-core/common/signal"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,6 +14,9 @@ func NewTempUDPConn(udpConn net.PacketConn, tcpConn net.Conn, expectedRemote *ne
|
|||||||
PacketConn: udpConn,
|
PacketConn: udpConn,
|
||||||
AssociatedTCPConn: tcpConn,
|
AssociatedTCPConn: tcpConn,
|
||||||
}
|
}
|
||||||
|
t.Timer = signal.CancelAfterInactivity(context.Background(), func() {
|
||||||
|
t.Close()
|
||||||
|
}, net.ConnIdleTimeout)
|
||||||
t.ExpectedRemote.Store(expectedRemote)
|
t.ExpectedRemote.Store(expectedRemote)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
@@ -60,9 +63,7 @@ func (c *TempUDPConn) RemoteAddr() net.Addr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *TempUDPConn) SetTimeout(d time.Duration) {
|
func (c *TempUDPConn) SetTimeout(d time.Duration) {
|
||||||
c.Timer = signal.CancelAfterInactivity(context.Background(), func() {
|
c.Timer.SetTimeout(d)
|
||||||
c.Close()
|
|
||||||
}, d)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TempUDPConn) Close() error {
|
func (c *TempUDPConn) Close() error {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func KeyLogWriterFromConfig(c *Config) io.Writer {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0o600)
|
writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors.LogErrorInner(context.Background(), err, "failed to open ", c.MasterKeyLog, " as master key log")
|
errors.LogErrorInner(context.Background(), err, "failed to open ", c.MasterKeyLog, " as master key log")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(c.MasterKeyLog) > 0 && c.MasterKeyLog != "none" {
|
if len(c.MasterKeyLog) > 0 && c.MasterKeyLog != "none" {
|
||||||
writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0o600)
|
writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors.LogErrorInner(context.Background(), err, "failed to open ", c.MasterKeyLog, " as master key log")
|
errors.LogErrorInner(context.Background(), err, "failed to open ", c.MasterKeyLog, " as master key log")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user