blob: 3d2f69d87ad50b18b80ab19462818efda826c326 (
plain) (
blame)
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
|
/*
Package proxy is a minetest reverse proxy for multiple servers.
It also provides an API for plugins.
*/
package proxy
import (
"log"
"os"
"path/filepath"
"regexp"
"strings"
"sync"
)
const (
latestSerializeVer = 28
latestProtoVer = 39
versionString = "5.4.1"
maxPlayerNameLen = 20
bytesPerMediaBunch = 5000
)
var playerNameChars = regexp.MustCompile("^[a-zA-Z0-9-_]+$")
var proxyDir string
var proxyDirOnce sync.Once
// Path prepends the directory the executable is in to the given path.
// It does not follow symlinks.
func Path(path ...string) string {
proxyDirOnce.Do(func() {
executable, err := os.Executable()
if err != nil {
log.Fatal(err)
}
proxyDir = filepath.Dir(executable)
})
return proxyDir + "/" + strings.Join(path, "")
}
|