mirror of
https://github.com/yhl452493373/frps-panel.git
synced 2026-04-04 14:27:00 +08:00
start to config with toml (not finish)
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"frps-panel/pkg/server"
|
||||
"frps-panel/pkg/server/controller"
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
"github.com/spf13/cobra"
|
||||
"gopkg.in/ini.v1"
|
||||
"io/fs"
|
||||
@@ -69,6 +70,25 @@ func Execute() {
|
||||
}
|
||||
|
||||
func ParseConfigFile(file string) (controller.HandleController, server.TLS, error) {
|
||||
|
||||
var config Config
|
||||
readFile, _ := os.ReadFile("/Volumes/Working/Works/Git Sources/frps-panel/config/frps-panel.toml")
|
||||
_ = toml.Unmarshal(readFile, &config)
|
||||
log.Printf("%v", config)
|
||||
f, err := os.Create("/Volumes/Working/Works/Git Sources/frps-panel/config/frps-panel-new.toml")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := toml.NewEncoder(f).Encode(config); err != nil {
|
||||
// failed to encode
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := f.Close(); err != nil {
|
||||
// failed to close the file
|
||||
log.Fatal(err)
|
||||
|
||||
}
|
||||
|
||||
common := controller.CommonInfo{}
|
||||
users := make(map[string]controller.TokenInfo)
|
||||
ports := make(map[string][]string)
|
||||
@@ -253,3 +273,7 @@ func ParseConfigFile(file string) (controller.HandleController, server.TLS, erro
|
||||
Version: version,
|
||||
}, tls, nil
|
||||
}
|
||||
|
||||
func decode() {
|
||||
|
||||
}
|
||||
|
||||
31
cmd/frps-panel/config.go
Normal file
31
cmd/frps-panel/config.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
type Config struct {
|
||||
Common CommonInfo
|
||||
Tokens []TokenInfo
|
||||
}
|
||||
|
||||
type CommonInfo struct {
|
||||
PluginAddr string `toml:"plugin_addr" commented:"true"`
|
||||
PluginPort int `toml:"plugin_port"`
|
||||
AdminUser string `toml:"admin_user"`
|
||||
AdminPwd string `toml:"admin_pwd"`
|
||||
AdminKeepTime int `toml:"admin_keep_time"`
|
||||
TlsMode bool `toml:"tls_mode"`
|
||||
TlsCertFile string `toml:"tls_cert_file"`
|
||||
TlsKeyFile string `toml:"tls_key_file"`
|
||||
DashboardAddr string `toml:"dashboard_addr"`
|
||||
DashboardPort int `toml:"dashboard_port"`
|
||||
DashboardUser string `toml:"dashboard_user"`
|
||||
DashboardPwd string `toml:"dashboard_pwd"`
|
||||
}
|
||||
|
||||
type TokenInfo struct {
|
||||
User string `toml:"user" json:"user" form:"user"`
|
||||
Token string `toml:"token" json:"token" form:"token"`
|
||||
Comment string `toml:"comment" json:"comment" form:"comment"`
|
||||
Ports []any `toml:"ports" json:"ports" from:"ports"`
|
||||
Domains []string `toml:"domains" json:"domains" from:"domains"`
|
||||
Subdomains []string `toml:"subdomains" json:"subdomains" from:"subdomains"`
|
||||
Status bool `toml:"status" json:"status" form:"status"`
|
||||
}
|
||||
Reference in New Issue
Block a user