mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-28 03:50:10 +00:00
Compare commits
2 Commits
c39a9e80e7
...
43e36ee6fc
Author | SHA1 | Date | |
---|---|---|---|
43e36ee6fc | |||
53c9569a37 |
@ -54,6 +54,7 @@ builds:
|
|||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
- darwin
|
- darwin
|
||||||
|
- windows
|
||||||
goarch:
|
goarch:
|
||||||
- arm
|
- arm
|
||||||
- arm64
|
- arm64
|
||||||
|
@ -122,6 +122,32 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
|
<span class="heading">{{ .lang.Proxy.title }}</span>
|
||||||
|
<p class="content my-2" id="proxy-description">{{ .lang.Proxy.description }}</p>
|
||||||
|
<label class="row switch pb-4">
|
||||||
|
<input type="checkbox" class="mr-2" id="advanced-proxy"><span>{{ .lang.Strings.enabled }}</span>
|
||||||
|
</label>
|
||||||
|
<label class="label">
|
||||||
|
<span>{{ .lang.Proxy.protocol }}</span>
|
||||||
|
<div class="select ~neutral @low mt-4 mb-2">
|
||||||
|
<select id="advanced-proxy_protocol">
|
||||||
|
<option value="http">HTTP</option>
|
||||||
|
<option value="socks">SOCKS5</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<label class="label">
|
||||||
|
<span class="mt-4">{{ .lang.Proxy.address }}</span>
|
||||||
|
<input type="text" class="input ~neutral @low mt-4 mb-2" id="advanced-proxy_address">
|
||||||
|
</label>
|
||||||
|
<label class="label">
|
||||||
|
<span class="mt-4">{{ .lang.Strings.username }}</span>
|
||||||
|
<input type="text" class="input ~neutral @low mt-4 mb-2" id="advanced-proxy_user">
|
||||||
|
</label>
|
||||||
|
<label class="label">
|
||||||
|
<span class="mt-4">{{ .lang.Strings.password }}</span>
|
||||||
|
<input type="text" class="input ~neutral @low mt-4 mb-2" id="advanced-proxy_password">
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<section class="section ~neutral banner footer flex-expand middle">
|
<section class="section ~neutral banner footer flex-expand middle">
|
||||||
|
1
lang.go
1
lang.go
@ -116,6 +116,7 @@ type setupLang struct {
|
|||||||
EndPage langSection `json:"endPage"`
|
EndPage langSection `json:"endPage"`
|
||||||
General langSection `json:"general"`
|
General langSection `json:"general"`
|
||||||
Updates langSection `json:"updates"`
|
Updates langSection `json:"updates"`
|
||||||
|
Proxy langSection `json:"proxy"`
|
||||||
Language langSection `json:"language"`
|
Language langSection `json:"language"`
|
||||||
Login langSection `json:"login"`
|
Login langSection `json:"login"`
|
||||||
JellyfinEmby langSection `json:"jellyfinEmby"`
|
JellyfinEmby langSection `json:"jellyfinEmby"`
|
||||||
|
@ -18,11 +18,12 @@
|
|||||||
"apiKey": "API Key",
|
"apiKey": "API Key",
|
||||||
"error": "Error",
|
"error": "Error",
|
||||||
"errorInvalidUserPass": "Invalid username/password.",
|
"errorInvalidUserPass": "Invalid username/password.",
|
||||||
"errorNotAdmin": "User is not allowed to manage server.",
|
"errorNotAdmin": "User is not aEnabledllowed to manage server.",
|
||||||
"errorUserDisabled": "User may be disabled.",
|
"errorUserDisabled": "User may be disabled.",
|
||||||
"error404": "404, check the internal URL.",
|
"error404": "404, check the internal URL.",
|
||||||
"errorConnectionRefused": "Connection refused.",
|
"errorConnectionRefused": "Connection refused.",
|
||||||
"errorUnknown": "Unknown error, check app logs."
|
"errorUnknown": "Unknown error, check app logs.",
|
||||||
|
"errorProxy": "Proxy configuration invalid."
|
||||||
},
|
},
|
||||||
"startPage": {
|
"startPage": {
|
||||||
"welcome": "Welcome!",
|
"welcome": "Welcome!",
|
||||||
@ -62,6 +63,12 @@
|
|||||||
"stable": "Stable",
|
"stable": "Stable",
|
||||||
"unstable": "Unstable"
|
"unstable": "Unstable"
|
||||||
},
|
},
|
||||||
|
"proxy": {
|
||||||
|
"title": "Proxy",
|
||||||
|
"description": "Have jfa-go make all connections through a HTTP/SOCKS5 proxy. Connection to Jellyfin will be tested through this.",
|
||||||
|
"protocol": "Protocol",
|
||||||
|
"address": "Address (Including Port)"
|
||||||
|
},
|
||||||
"login": {
|
"login": {
|
||||||
"title": "Login",
|
"title": "Login",
|
||||||
"description": "To access the admin page, you need to login with a method below:",
|
"description": "To access the admin page, you need to login with a method below:",
|
||||||
|
36
setup.go
36
setup.go
@ -7,6 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/hrfee/jfa-go/easyproxy"
|
||||||
"github.com/hrfee/mediabrowser"
|
"github.com/hrfee/mediabrowser"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,10 +48,15 @@ func (app *appContext) ServeSetup(gc *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type testReq struct {
|
type testReq struct {
|
||||||
ServerType string `json:"type"`
|
ServerType string `json:"type"`
|
||||||
Server string `json:"server"`
|
Server string `json:"server"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
|
Proxy bool `json:"proxy"`
|
||||||
|
ProxyProtocol string `json:"proxy_protocol,omitempty"`
|
||||||
|
ProxyAddress string `json:"proxy_address,omitempty"`
|
||||||
|
ProxyUsername string `json:"proxy_user,omitempty"`
|
||||||
|
ProxyPassword string `json:"proxy_password,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *appContext) TestJF(gc *gin.Context) {
|
func (app *appContext) TestJF(gc *gin.Context) {
|
||||||
@ -64,6 +70,26 @@ func (app *appContext) TestJF(gc *gin.Context) {
|
|||||||
serverType = mediabrowser.EmbyServer
|
serverType = mediabrowser.EmbyServer
|
||||||
}
|
}
|
||||||
tempjf, _ := mediabrowser.NewServer(serverType, req.Server, "jfa-go-setup", app.version, "auth", "auth", mediabrowser.NewNamedTimeoutHandler("authJF", req.Server, true), 30)
|
tempjf, _ := mediabrowser.NewServer(serverType, req.Server, "jfa-go-setup", app.version, "auth", "auth", mediabrowser.NewNamedTimeoutHandler("authJF", req.Server, true), 30)
|
||||||
|
|
||||||
|
if req.Proxy {
|
||||||
|
conf := easyproxy.ProxyConfig{
|
||||||
|
Protocol: easyproxy.HTTP,
|
||||||
|
Addr: req.ProxyAddress,
|
||||||
|
User: req.ProxyUsername,
|
||||||
|
Password: req.ProxyPassword,
|
||||||
|
}
|
||||||
|
if strings.Contains(req.ProxyProtocol, "socks") {
|
||||||
|
conf.Protocol = easyproxy.SOCKS5
|
||||||
|
}
|
||||||
|
|
||||||
|
transport, err := easyproxy.NewTransport(conf)
|
||||||
|
if err != nil {
|
||||||
|
respond(400, "errorProxy", gc)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tempjf.SetTransport(transport)
|
||||||
|
}
|
||||||
|
|
||||||
user, status, err := tempjf.Authenticate(req.Username, req.Password)
|
user, status, err := tempjf.Authenticate(req.Username, req.Password)
|
||||||
if !(status == 200 || status == 204) || err != nil {
|
if !(status == 200 || status == 204) || err != nil {
|
||||||
msg := ""
|
msg := ""
|
||||||
@ -126,6 +152,7 @@ func (st *Storage) loadLangSetup(filesystems ...fs.FS) error {
|
|||||||
patchLang(&lang.Strings, &fallback.Strings, &english.Strings)
|
patchLang(&lang.Strings, &fallback.Strings, &english.Strings)
|
||||||
patchLang(&lang.StartPage, &fallback.StartPage, &english.StartPage)
|
patchLang(&lang.StartPage, &fallback.StartPage, &english.StartPage)
|
||||||
patchLang(&lang.Updates, &fallback.Updates, &english.Updates)
|
patchLang(&lang.Updates, &fallback.Updates, &english.Updates)
|
||||||
|
patchLang(&lang.Proxy, &fallback.Proxy, &english.Proxy)
|
||||||
patchLang(&lang.EndPage, &fallback.EndPage, &english.EndPage)
|
patchLang(&lang.EndPage, &fallback.EndPage, &english.EndPage)
|
||||||
patchLang(&lang.Language, &fallback.Language, &english.Language)
|
patchLang(&lang.Language, &fallback.Language, &english.Language)
|
||||||
patchLang(&lang.Login, &fallback.Login, &english.Login)
|
patchLang(&lang.Login, &fallback.Login, &english.Login)
|
||||||
@ -144,6 +171,7 @@ func (st *Storage) loadLangSetup(filesystems ...fs.FS) error {
|
|||||||
patchLang(&lang.Strings, &english.Strings)
|
patchLang(&lang.Strings, &english.Strings)
|
||||||
patchLang(&lang.StartPage, &english.StartPage)
|
patchLang(&lang.StartPage, &english.StartPage)
|
||||||
patchLang(&lang.Updates, &english.Updates)
|
patchLang(&lang.Updates, &english.Updates)
|
||||||
|
patchLang(&lang.Proxy, &english.Proxy)
|
||||||
patchLang(&lang.EndPage, &english.EndPage)
|
patchLang(&lang.EndPage, &english.EndPage)
|
||||||
patchLang(&lang.Language, &english.Language)
|
patchLang(&lang.Language, &english.Language)
|
||||||
patchLang(&lang.Login, &english.Login)
|
patchLang(&lang.Login, &english.Login)
|
||||||
|
22
ts/setup.ts
22
ts/setup.ts
@ -85,6 +85,13 @@ class Checkbox {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._el.hasAttribute("checked")) {
|
||||||
|
this._el.checked = true;
|
||||||
|
} else {
|
||||||
|
this._el.checked = false;
|
||||||
|
}
|
||||||
|
this.broadcast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,10 +322,14 @@ const settings = {
|
|||||||
"tls": new Checkbox(get("advanced-tls"), "", false, "advanced", "tls"),
|
"tls": new Checkbox(get("advanced-tls"), "", false, "advanced", "tls"),
|
||||||
"tls_port": new Input(get("advanced-tls_port"), "", "", "tls", true, "advanced"),
|
"tls_port": new Input(get("advanced-tls_port"), "", "", "tls", true, "advanced"),
|
||||||
"tls_cert": new Input(get("advanced-tls_cert"), "", "", "tls", true, "advanced"),
|
"tls_cert": new Input(get("advanced-tls_cert"), "", "", "tls", true, "advanced"),
|
||||||
"tls_key": new Input(get("advanced-tls_key"), "", "", "tls", true, "advanced")
|
"tls_key": new Input(get("advanced-tls_key"), "", "", "tls", true, "advanced"),
|
||||||
|
"proxy": new Checkbox(get("advanced-proxy"), "", false, "advanced", "proxy"),
|
||||||
|
"proxy_protocol": new Select(get("advanced-proxy_protocol"), "proxy", true, "advanced"),
|
||||||
|
"proxy_address": new Input(get("advanced-proxy_address"), "", "", "proxy", true, "advanced"),
|
||||||
|
"proxy_user": new Input(get("advanced-proxy_user"), "", "", "proxy", true, "advanced"),
|
||||||
|
"proxy_password": new Input(get("advanced-proxy_password"), "", "", "proxy", true, "advanced")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkTheme = () => {
|
const checkTheme = () => {
|
||||||
if (settings["ui"]["theme"].value.includes("Dark")) {
|
if (settings["ui"]["theme"].value.includes("Dark")) {
|
||||||
document.documentElement.classList.add("dark-theme");
|
document.documentElement.classList.add("dark-theme");
|
||||||
@ -553,7 +564,12 @@ window.onpopstate = (event: PopStateEvent) => {
|
|||||||
"type": settings["jellyfin"]["type"].value,
|
"type": settings["jellyfin"]["type"].value,
|
||||||
"server": settings["jellyfin"]["server"].value,
|
"server": settings["jellyfin"]["server"].value,
|
||||||
"username": settings["jellyfin"]["username"].value,
|
"username": settings["jellyfin"]["username"].value,
|
||||||
"password": settings["jellyfin"]["password"].value
|
"password": settings["jellyfin"]["password"].value,
|
||||||
|
"proxy": settings["advanced"]["proxy"].value == "true",
|
||||||
|
"proxy_protocol": settings["advanced"]["proxy_protocol"].value,
|
||||||
|
"proxy_address": settings["advanced"]["proxy_address"].value,
|
||||||
|
"proxy_user": settings["advanced"]["proxy_user"].value,
|
||||||
|
"proxy_password": settings["advanced"]["proxy_password"].value
|
||||||
};
|
};
|
||||||
_post("/jellyfin/test", send, (req: XMLHttpRequest) => {
|
_post("/jellyfin/test", send, (req: XMLHttpRequest) => {
|
||||||
if (req.readyState == 4) {
|
if (req.readyState == 4) {
|
||||||
|
Loading…
Reference in New Issue
Block a user