Detect FreeBSD linuxemu with syscall.Uname
This commit is contained in:
parent
e44c5e1256
commit
3d8e8e2543
4
Makefile
4
Makefile
|
|
@ -1,4 +1,4 @@
|
|||
SOURCES=Makefile main.go main_release.go main_debug.go config.go config_release.go config_template.go system.go system_windows.go system_unix.go
|
||||
SOURCES=Makefile main.go main_release.go main_debug.go config.go config_release.go config_template.go system.go system_windows.go system_linux.go system_darwin.go
|
||||
GARBLE_BIN = $(shell go env GOPATH)/bin/garble
|
||||
GARBLE_CMD = $(GARBLE_BIN) -literals -tiny
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ test: socks5-ssh-proxy
|
|||
test-release: socks5-ssh-proxy.release
|
||||
./socks5-ssh-proxy.release
|
||||
socks5-ssh-proxy: $(SOURCES)
|
||||
go build -o $@
|
||||
GOOS=linux GOARCH=amd64 go build -tags release,linux -o $@
|
||||
socks5-ssh-proxy.release: resources $(SOURCES) $(GARBLE_BIN)
|
||||
GOOS=darwin GOARCH=amd64 $(GARBLE_CMD) build -tags release -o $@
|
||||
upx $@
|
||||
|
|
|
|||
|
|
@ -156,6 +156,8 @@ func systemIgnoreAllSignals() {
|
|||
}
|
||||
|
||||
func systemOSDetect() {
|
||||
systemGetUname()
|
||||
|
||||
wineVersion := systemGetWINEVersion()
|
||||
log.Println("WINE version", wineVersion)
|
||||
log.Println("IsUserRoot", systemIsUserRoot())
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
//go:build darwin
|
||||
// +build darwin
|
||||
|
||||
//
|
||||
package main
|
||||
|
||||
func systemGetWINEVersion() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func systemGetUname() {
|
||||
}
|
||||
|
||||
func systemIsUserRoot() bool {
|
||||
return false
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"syscall"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func systemGetWINEVersion() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func systemGetUname() {
|
||||
var uts syscall.Utsname
|
||||
|
||||
err := syscall.Uname(&uts)
|
||||
if err != nil {
|
||||
log.Println("Error getting system information:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Convert the byte arrays to strings
|
||||
sysname := int8SliceToString(uts.Sysname[:])
|
||||
release := int8SliceToString(uts.Release[:])
|
||||
version := int8SliceToString(uts.Version[:])
|
||||
|
||||
// Check for FreeBSD Linux emulation specific indicators
|
||||
log.Println("syscall.Uname:", "(sysname)", sysname, "(release)", release, "(version)", version)
|
||||
if strings.Contains(sysname, "Linux") && strings.Contains(version, "FreeBSD") {
|
||||
log.Println("Running under FreeBSD linuxemu")
|
||||
}
|
||||
}
|
||||
|
||||
// int8SliceToString converts a slice of int8 to a string.
|
||||
func int8SliceToString(int8Slice []int8) string {
|
||||
// Create a byte slice with the same length as the int8 slice
|
||||
byteSlice := make([]byte, len(int8Slice))
|
||||
for i, v := range int8Slice {
|
||||
byteSlice[i] = byte(v)
|
||||
}
|
||||
return string(byteSlice)
|
||||
}
|
||||
|
||||
func systemIsUserRoot() bool {
|
||||
return false
|
||||
}
|
||||
|
|
@ -26,6 +26,9 @@ func systemGetWINEVersion() string {
|
|||
return wineVersion
|
||||
}
|
||||
|
||||
func systemGetUname() {
|
||||
}
|
||||
|
||||
func systemIsUserRoot() bool {
|
||||
root := true
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue