Skip to content

Commit c174b31

Browse files
authored
feat: use vialite auto latest subprocess runtime
1 parent fbf722d commit c174b31

8 files changed

Lines changed: 69 additions & 21 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ graph LR
6060
style E fill:#a0526d,stroke:#222,stroke-width:2px
6161
```
6262

63+
## Java Version Compatibility
64+
65+
Gate can start **Via-powered backend protocol translation** through managed
66+
vialite, so Java clients can join backend servers running different Minecraft
67+
versions without running a separate Via sidecar.
68+
69+
Enable managed Via in classic proxy mode with:
70+
71+
```yaml
72+
config:
73+
via:
74+
enabled: true
75+
```
76+
77+
Gate starts the native vialite subprocess, resolves the latest stable vialite
78+
release automatically, downloads the checksummed artifact into the local cache,
79+
and routes backend connections through it. Exact release pins, offline mode, and
80+
local artifact paths remain available for controlled deployments, but no manual
81+
version setting is required for the default path.
82+
6383
## Gate Lite Mode
6484
6585
Gate has a Lite Mode which is a lightweight version of Gate that can expose

config.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,18 @@ config:
9595
# Can also be set via environment variable: GATE_BUNGEEGUARD_SECRET
9696
#bungeeGuardSecret: secret_here
9797
# Via backend protocol translation for Gate classic mode.
98-
# This loads vialite in-process at startup and routes configured classic backend connections
98+
# This starts vialite at startup and routes configured classic backend connections
9999
# through Via-compatible translation before Gate dials the backend.
100100
# Not used in lite mode. Changes require a Gate restart.
101101
via:
102102
enabled: false
103-
# Options: embedded, subprocess
104-
mode: embedded
103+
# Options: subprocess, embedded. Subprocess uses released vialite artifacts and is the default.
104+
mode: subprocess
105105
# Optional local bind for the native runtime's internal loopback listener.
106106
#bind: 127.0.0.1:0
107107
# Optional artifact overrides.
108108
#libraryPath: /opt/vialite/libvialite.so
109109
#binaryPath: /opt/vialite/vialite
110-
#version: v0.1.0
111-
#mirror: https://github.com/minekube/vialite/releases/download
112110
#offline: false
113111
# Proxy protocol (HA-Proxy) determines whether Gate should support proxy protocol for players.
114112
# Do not enable this if you don't know what it is.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ require (
3535
go.minekube.com/common v0.3.0
3636
go.minekube.com/connect v0.6.2
3737
go.minekube.com/geyserlite v0.3.14
38-
go.minekube.com/vialite v0.1.0
38+
go.minekube.com/vialite v0.2.7
3939
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0
4040
go.opentelemetry.io/otel v1.41.0
4141
go.opentelemetry.io/otel/metric v1.41.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ go.minekube.com/connect v0.6.2 h1:RajPc7YgqygcOviV2g4xetL3J0Wzi8b/lsYXUzIltxE=
254254
go.minekube.com/connect v0.6.2/go.mod h1:28k11I4RyzUfAL3AkOXt3atzjeOFAC8eqbCMwsYKAb0=
255255
go.minekube.com/geyserlite v0.3.14 h1:+cSN9o/b5jEOHeym/uXvt5MEoGnrYloJidrVe9K9pWo=
256256
go.minekube.com/geyserlite v0.3.14/go.mod h1:yy0/M0zSD6X3FoQMwtmf5Jn+7YFM7AZWamKw0E8fnOE=
257-
go.minekube.com/vialite v0.1.0 h1:RMnNeDcDKchIs+N5KqxOzCK9tgkrVPjgUgjU5ARdn5o=
258-
go.minekube.com/vialite v0.1.0/go.mod h1:W9L1l8/b/GsLmkw1BW4wijaaPj/zV3OdrtYJgWdkhxE=
257+
go.minekube.com/vialite v0.2.7 h1:G5OuIt0qN4xfowW2rahZhb8zzMark5nI6AqubVBn6gQ=
258+
go.minekube.com/vialite v0.2.7/go.mod h1:W9L1l8/b/GsLmkw1BW4wijaaPj/zV3OdrtYJgWdkhxE=
259259
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
260260
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
261261
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=

pkg/configs/config.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,18 @@ config:
9595
# Can also be set via environment variable: GATE_BUNGEEGUARD_SECRET
9696
#bungeeGuardSecret: secret_here
9797
# Via backend protocol translation for Gate classic mode.
98-
# This loads vialite in-process at startup and routes configured classic backend connections
98+
# This starts vialite at startup and routes configured classic backend connections
9999
# through Via-compatible translation before Gate dials the backend.
100100
# Not used in lite mode. Changes require a Gate restart.
101101
via:
102102
enabled: false
103-
# Options: embedded, subprocess
104-
mode: embedded
103+
# Options: subprocess, embedded. Subprocess uses released vialite artifacts and is the default.
104+
mode: subprocess
105105
# Optional local bind for the native runtime's internal loopback listener.
106106
#bind: 127.0.0.1:0
107107
# Optional artifact overrides.
108108
#libraryPath: /opt/vialite/libvialite.so
109109
#binaryPath: /opt/vialite/vialite
110-
#version: v0.1.0
111-
#mirror: https://github.com/minekube/vialite/releases/download
112110
#offline: false
113111
# Proxy protocol (HA-Proxy) determines whether Gate should support proxy protocol for players.
114112
# Do not enable this if you don't know what it is.

pkg/edition/java/proxy/vialite.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
//go:build !musl && !windows
1+
//go:build !musl
22

33
package proxy
44

55
import (
66
"context"
77
"fmt"
88
"net"
9+
"runtime"
910
"strings"
1011
"sync"
1112
"time"
@@ -159,7 +160,7 @@ func (r *viaManagedRunner) BackendDialAddress(name string) (string, error) {
159160

160161
func (r *viaManagedRunner) options() (vialite.Options, error) {
161162
opts := vialite.Options{
162-
Mode: viaMode(r.cfg.Via.Mode),
163+
Mode: viaMode(r.cfg.Via.Mode, runtime.GOOS, r.cfg.Via.LibraryPath),
163164
Bind: r.cfg.Via.Bind,
164165
LibraryPath: r.cfg.Via.LibraryPath,
165166
BinaryPath: r.cfg.Via.BinaryPath,
@@ -178,12 +179,18 @@ func (r *viaManagedRunner) options() (vialite.Options, error) {
178179
return opts, nil
179180
}
180181

181-
func viaMode(mode string) vialite.Mode {
182-
switch mode {
183-
case "subprocess":
182+
func viaMode(mode, goos, libraryPath string) vialite.Mode {
183+
if mode == "" {
184184
return vialite.ModeSubprocess
185-
default:
185+
}
186+
if goos == "windows" && libraryPath == "" && mode == "embedded" {
187+
return vialite.ModeSubprocess
188+
}
189+
switch mode {
190+
case "embedded":
186191
return vialite.ModeEmbedded
192+
default:
193+
return vialite.ModeSubprocess
187194
}
188195
}
189196

pkg/edition/java/proxy/vialite_disabled.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build musl || windows
1+
//go:build musl
22

33
package proxy
44

pkg/edition/java/proxy/vialite_test.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !musl && !windows
1+
//go:build !musl
22

33
package proxy
44

@@ -216,6 +216,31 @@ func TestViaManagedRunnerOptionsMapConfig(t *testing.T) {
216216
}
217217
}
218218

219+
func TestViaModeDefaults(t *testing.T) {
220+
tests := []struct {
221+
name string
222+
mode string
223+
goos string
224+
libraryPath string
225+
want vialite.Mode
226+
}{
227+
{name: "linux empty defaults subprocess", mode: "", goos: "linux", want: vialite.ModeSubprocess},
228+
{name: "linux explicit embedded", mode: "embedded", goos: "linux", want: vialite.ModeEmbedded},
229+
{name: "linux subprocess", mode: "subprocess", goos: "linux", want: vialite.ModeSubprocess},
230+
{name: "windows empty defaults subprocess", mode: "", goos: "windows", want: vialite.ModeSubprocess},
231+
{name: "windows explicit embedded uses subprocess", mode: "embedded", goos: "windows", want: vialite.ModeSubprocess},
232+
{name: "windows custom library explicit embedded", mode: "embedded", goos: "windows", libraryPath: "C:\\vialite\\libvialite.dll", want: vialite.ModeEmbedded},
233+
{name: "windows subprocess", mode: "subprocess", goos: "windows", want: vialite.ModeSubprocess},
234+
}
235+
for _, tt := range tests {
236+
t.Run(tt.name, func(t *testing.T) {
237+
if got := viaMode(tt.mode, tt.goos, tt.libraryPath); got != tt.want {
238+
t.Fatalf("viaMode(%q, %q, %q) = %v, want %v", tt.mode, tt.goos, tt.libraryPath, got, tt.want)
239+
}
240+
})
241+
}
242+
}
243+
219244
func TestViaManagedRunnerOptionsUseConfiguredServerNames(t *testing.T) {
220245
cfg := &config.Config{
221246
Servers: map[string]string{

0 commit comments

Comments
 (0)