mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 11:04:02 +03:00
support for test dc1-3
loading custom dc ips from config
This commit is contained in:
Generated
+10
@@ -0,0 +1,10 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="ASK" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GoImports">
|
||||
<option name="excludedPackages">
|
||||
<array>
|
||||
<option value="golang.org/x/net/context" />
|
||||
</array>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GoLinterFmtOnSave">
|
||||
<option name="enabledOnSave" value="true" />
|
||||
</component>
|
||||
<component name="GoLinterSettings">
|
||||
<option name="customConfigFile" value="$PROJECT_DIR$/.golangci.toml" />
|
||||
<option name="useCustomConfigFile" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="GoLinter" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="mysql-connector-python" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/mtg.iml" filepath="$PROJECT_DIR$/.idea/mtg.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
+13
-1
@@ -25,6 +25,18 @@ var TelegramCoreAddresses = map[int][]string{
|
||||
},
|
||||
203: {
|
||||
"91.105.192.100:443",
|
||||
"[2a0a:f280:0203:000a:5000:0000:0000:0100]:443",
|
||||
"[2a0a:f280:0203:a:5000::100]:443",
|
||||
},
|
||||
10001: {
|
||||
"149.154.175.10:443",
|
||||
"[2001:b28:f23d:f001::e]:443",
|
||||
},
|
||||
10002: {
|
||||
"149.154.167.40:443",
|
||||
"[2001:67c:4e8:f002::e]:443",
|
||||
},
|
||||
10003: {
|
||||
"149.154.175.117:443",
|
||||
"[2001:b28:f23d:f003::e]:443",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -378,3 +378,42 @@ bind-to = "127.0.0.1:3129"
|
||||
http-path = "/"
|
||||
# prefix for metrics for prometheus
|
||||
metric-prefix = "mtg"
|
||||
|
||||
[dc]
|
||||
dc1 = [
|
||||
"149.154.175.59:443",
|
||||
"149.154.175.54:443",
|
||||
"[2001:b28:f23d:f001::a]:443"
|
||||
]
|
||||
dc2 = [
|
||||
"149.154.167.41:443",
|
||||
"149.154.167.151:443",
|
||||
"[2001:67c:4e8:f002::a]:443",
|
||||
"[2001:67c:4e8:f002::b]:443"
|
||||
]
|
||||
dc3 = [
|
||||
"149.154.175.100:443",
|
||||
"[2001:b28:f23d:f003::a]:443"
|
||||
]
|
||||
dc4 = [
|
||||
"149.154.167.92:443",
|
||||
"149.154.165.111:443",
|
||||
"[2001:67c:4e8:f004::a]:443",
|
||||
"[2001:67c:4e8:f004::b]:443"
|
||||
]
|
||||
dc5 = [
|
||||
"91.108.56.115:443",
|
||||
"[2001:b28:f23f:f005::a]:443"
|
||||
]
|
||||
dc10001 = [
|
||||
"149.154.175.10:443",
|
||||
"[2001:b28:f23d:f001::e]:443"
|
||||
]
|
||||
dc10002 = [
|
||||
"149.154.167.40:443",
|
||||
"[2001:67c:4e8:f002::e]:443"
|
||||
]
|
||||
dc10003 = [
|
||||
"149.154.175.117:443",
|
||||
"[2001:b28:f23d:f003::e]:443"
|
||||
]
|
||||
@@ -91,6 +91,17 @@ type Config struct {
|
||||
MetricPrefix TypeMetricPrefix `json:"metricPrefix"`
|
||||
} `json:"prometheus"`
|
||||
} `json:"stats"`
|
||||
DCs struct{
|
||||
DC1 []TypeHostPort `json:"dc1"`
|
||||
DC2 []TypeHostPort `json:"dc2"`
|
||||
DC3 []TypeHostPort `json:"dc3"`
|
||||
DC4 []TypeHostPort `json:"dc4"`
|
||||
DC5 []TypeHostPort `json:"dc5"`
|
||||
DC203 []TypeHostPort `json:"dc203"`
|
||||
DC10001 []TypeHostPort `json:"dc10001"`
|
||||
DC10002[]TypeHostPort `json:"dc10002"`
|
||||
DC10003 []TypeHostPort `json:"dc10003"`
|
||||
} `json:"dc"`
|
||||
}
|
||||
|
||||
func (c *Config) GetConcurrency(defaultValue uint) uint {
|
||||
|
||||
@@ -84,6 +84,17 @@ type tomlConfig struct {
|
||||
MetricPrefix string `toml:"metric-prefix" json:"metricPrefix,omitempty"`
|
||||
} `toml:"prometheus" json:"prometheus,omitempty"`
|
||||
} `toml:"stats" json:"stats,omitempty"`
|
||||
DCs struct{
|
||||
DC1 []string `toml:"dc1" json:"dc1,omitempty"`
|
||||
DC2 []string `toml:"dc2" json:"dc2,omitempty"`
|
||||
DC3 []string `toml:"dc3" json:"dc3,omitempty"`
|
||||
DC4 []string `toml:"dc4" json:"dc4,omitempty"`
|
||||
DC5 []string `toml:"dc5" json:"dc5,omitempty"`
|
||||
DC203 []string `toml:"dc203" json:"dc203,omitempty"`
|
||||
DC10001 []string `toml:"dc10001" json:"dc10001,omitempty"`
|
||||
DC10002 []string `toml:"dc10002" json:"dc10002,omitempty"`
|
||||
DC10003 []string `toml:"dc10003" json:"dc10003,omitempty"`
|
||||
} `toml:"dc" json:"dc,omitempty"`
|
||||
}
|
||||
|
||||
func Parse(rawData []byte) (*Config, error) {
|
||||
|
||||
@@ -2,11 +2,82 @@ package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/9seconds/mtg/v2/essentials"
|
||||
"github.com/9seconds/mtg/v2/internal/config"
|
||||
)
|
||||
|
||||
func readCustomDC(cfg *config.Config) {
|
||||
if len(cfg.DCs.DC1) > 0 {
|
||||
var ips []string
|
||||
for _, addr := range cfg.DCs.DC1 {
|
||||
ips = append(ips, addr.Value)
|
||||
}
|
||||
essentials.TelegramCoreAddresses[1] = ips
|
||||
}
|
||||
if len(cfg.DCs.DC2) > 0 {
|
||||
var ips []string
|
||||
for _, addr := range cfg.DCs.DC2 {
|
||||
ips = append(ips, addr.Value)
|
||||
}
|
||||
essentials.TelegramCoreAddresses[2] = ips
|
||||
}
|
||||
if len(cfg.DCs.DC3) > 0 {
|
||||
var ips []string
|
||||
for _, addr := range cfg.DCs.DC3 {
|
||||
ips = append(ips, addr.Value)
|
||||
}
|
||||
essentials.TelegramCoreAddresses[3] = ips
|
||||
}
|
||||
if len(cfg.DCs.DC4) > 0 {
|
||||
var ips []string
|
||||
for _, addr := range cfg.DCs.DC4 {
|
||||
ips = append(ips, addr.Value)
|
||||
}
|
||||
essentials.TelegramCoreAddresses[4] = ips
|
||||
}
|
||||
if len(cfg.DCs.DC5) > 0 {
|
||||
var ips []string
|
||||
for _, addr := range cfg.DCs.DC5 {
|
||||
ips = append(ips, addr.Value)
|
||||
}
|
||||
essentials.TelegramCoreAddresses[5] = ips
|
||||
}
|
||||
if len(cfg.DCs.DC203) > 0 {
|
||||
var ips []string
|
||||
for _, addr := range cfg.DCs.DC203 {
|
||||
ips = append(ips, addr.Value)
|
||||
}
|
||||
essentials.TelegramCoreAddresses[203] = ips
|
||||
}
|
||||
|
||||
if len(cfg.DCs.DC10001) > 0 {
|
||||
var ips []string
|
||||
for _, addr := range cfg.DCs.DC10001 {
|
||||
ips = append(ips, addr.Value)
|
||||
}
|
||||
essentials.TelegramCoreAddresses[10001] = ips
|
||||
}
|
||||
if len(cfg.DCs.DC10002) > 0 {
|
||||
var ips []string
|
||||
for _, addr := range cfg.DCs.DC203 {
|
||||
ips = append(ips, addr.Value)
|
||||
}
|
||||
essentials.TelegramCoreAddresses[10002] = ips
|
||||
}
|
||||
if len(cfg.DCs.DC10003) > 0 {
|
||||
var ips []string
|
||||
for _, addr := range cfg.DCs.DC203 {
|
||||
ips = append(ips, addr.Value)
|
||||
}
|
||||
essentials.TelegramCoreAddresses[10003] = ips
|
||||
}
|
||||
log.Println(essentials.TelegramCoreAddresses)
|
||||
log.Println(cfg.DCs)
|
||||
}
|
||||
|
||||
func ReadConfig(path string) (*config.Config, error) {
|
||||
content, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
@@ -21,6 +92,7 @@ func ReadConfig(path string) (*config.Config, error) {
|
||||
if err := conf.Validate(); err != nil {
|
||||
return nil, fmt.Errorf("invalid config: %w", err)
|
||||
}
|
||||
readCustomDC(conf)
|
||||
|
||||
return conf, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user