V0.2.0 (#37)
* refactor go files, add headless telemost support * js crap -> ts crap * docker-build (#32) Co-authored-by: Mimocro <suzumagefag@gmail.com> * add headless telemost for creator app * UX improvements (#39) * Add search in split tunneling app list * Add captcha detection * Add autoclick settings * headless vk joiner * add headless telemost joiner * refactor go modules * redesign settings dialog * headless option in settings * headless joiner support in MainActivity * display headless vk status in statusBar * update ux for headless in creator app * fix double log render for headless mode in creator * unicode for cyrillic * add socks auth * put socksPort inf prefs, verify that port is free on start * proxy only mode * mask addresses in go network errors * update docker build, add file write logic for headless * increment release version, add make-release script --------- Co-authored-by: kulikov <user@Mac.lan> Co-authored-by: Mimocro <67226986+Mimocro@users.noreply.github.com> Co-authored-by: Mimocro <suzumagefag@gmail.com> Co-authored-by: senya <76913432+senya-sh@users.noreply.github.com>
This commit is contained in:
122 files changed
+9938
-3284
No files matched your search
@@ -0,0 +1,69 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
|
||||
"whitelist-bypass/relay/common"
|
||||
)
|
||||
|
||||
type TMConfig struct {
|
||||
AppVersion string
|
||||
SDKVersion string
|
||||
}
|
||||
|
||||
func fetchConfig() (TMConfig, error) {
|
||||
var cfg TMConfig
|
||||
|
||||
page, err := common.HttpGet("https://telemost.yandex.ru/")
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("failed to fetch telemost.yandex.ru: %w", err)
|
||||
}
|
||||
|
||||
stateRe := regexp.MustCompile(`<script[^>]*id="preloaded-state"[^>]*>([\s\S]*?)</script>`)
|
||||
stateMatch := stateRe.FindSubmatch(page)
|
||||
if stateMatch == nil {
|
||||
return cfg, fmt.Errorf("preloaded-state not found in page")
|
||||
}
|
||||
var state struct {
|
||||
Config struct {
|
||||
AppVersion string `json:"appVersion"`
|
||||
} `json:"config"`
|
||||
AppVersion string `json:"appVersion"`
|
||||
}
|
||||
if err := json.Unmarshal(stateMatch[1], &state); err != nil {
|
||||
return cfg, fmt.Errorf("failed to parse preloaded-state: %w", err)
|
||||
}
|
||||
cfg.AppVersion = state.Config.AppVersion
|
||||
if cfg.AppVersion == "" {
|
||||
cfg.AppVersion = state.AppVersion
|
||||
}
|
||||
if cfg.AppVersion == "" {
|
||||
return cfg, fmt.Errorf("appVersion not found in preloaded-state")
|
||||
}
|
||||
log.Printf("[config] appVersion=%s", cfg.AppVersion)
|
||||
|
||||
bundleRe := regexp.MustCompile(`https://telemost\.yastatic\.net/s3/telemost/_/main\.\w+\.[a-f0-9]+\.js`)
|
||||
bundleURL := bundleRe.FindString(string(page))
|
||||
if bundleURL == "" {
|
||||
return cfg, fmt.Errorf("main bundle URL not found in page")
|
||||
}
|
||||
log.Printf("[config] Found bundle: %s", bundleURL)
|
||||
|
||||
bundle, err := common.HttpGet(bundleURL)
|
||||
if err != nil {
|
||||
return cfg, fmt.Errorf("failed to fetch bundle: %w", err)
|
||||
}
|
||||
|
||||
sdkVerRe := regexp.MustCompile(`goloom-sdk\.(\d+\.\d+\.\d+)\.js`)
|
||||
if m := sdkVerRe.FindSubmatch(bundle); m != nil {
|
||||
cfg.SDKVersion = string(m[1])
|
||||
} else {
|
||||
return cfg, fmt.Errorf("goloom SDK version not found in bundle")
|
||||
}
|
||||
|
||||
log.Printf("[config] app=%s sdk=%s", cfg.AppVersion, cfg.SDKVersion)
|
||||
return cfg, nil
|
||||
}
|
||||
Reference in new issue
Block a user