mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	管理平台界面设置中增加“使用的DNS解析库”选项
This commit is contained in:
		@@ -93,6 +93,7 @@ func loadAdminUIConfig() (*systemconfigs.AdminUIConfig, error) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var config = &systemconfigs.AdminUIConfig{}
 | 
			
		||||
	config.DNSResolver.Type = nodeconfigs.DNSResolverTypeDefault // 默认值
 | 
			
		||||
	err = json.Unmarshal(resp.ValueJSON, config)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		logs.Println("[UI_MANAGER]" + err.Error())
 | 
			
		||||
@@ -108,7 +109,7 @@ func loadAdminUIConfig() (*systemconfigs.AdminUIConfig, error) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func defaultAdminUIConfig() *systemconfigs.AdminUIConfig {
 | 
			
		||||
	return &systemconfigs.AdminUIConfig{
 | 
			
		||||
	var config = &systemconfigs.AdminUIConfig{
 | 
			
		||||
		ProductName:        langs.DefaultMessage(codes.AdminUI_DefaultProductName),
 | 
			
		||||
		AdminSystemName:    langs.DefaultMessage(codes.AdminUI_DefaultSystemName),
 | 
			
		||||
		ShowOpenSourceInfo: true,
 | 
			
		||||
@@ -117,6 +118,8 @@ func defaultAdminUIConfig() *systemconfigs.AdminUIConfig {
 | 
			
		||||
		DefaultPageSize:    10,
 | 
			
		||||
		TimeZone:           nodeconfigs.DefaultTimeZoneLocation,
 | 
			
		||||
	}
 | 
			
		||||
	config.DNSResolver.Type = nodeconfigs.DNSResolverTypeDefault
 | 
			
		||||
	return config
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 修改时区
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ import (
 | 
			
		||||
	teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/events"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
 | 
			
		||||
	"github.com/iwind/TeaGo"
 | 
			
		||||
	"github.com/iwind/TeaGo/Tea"
 | 
			
		||||
	"github.com/iwind/TeaGo/lists"
 | 
			
		||||
@@ -87,6 +88,9 @@ func (this *AdminNode) Run() {
 | 
			
		||||
	// 启动API节点
 | 
			
		||||
	this.startAPINode()
 | 
			
		||||
 | 
			
		||||
	// 设置DNS相关
 | 
			
		||||
	this.setupDNS()
 | 
			
		||||
 | 
			
		||||
	// 启动IP库
 | 
			
		||||
	this.startIPLibrary()
 | 
			
		||||
 | 
			
		||||
@@ -254,6 +258,33 @@ func (this *AdminNode) addPortsToFirewall() {
 | 
			
		||||
	utils.AddPortsToFirewall(ports)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 设置DNS相关
 | 
			
		||||
func (this *AdminNode) setupDNS() {
 | 
			
		||||
	config, loadErr := configloaders.LoadAdminUIConfig()
 | 
			
		||||
	if loadErr != nil {
 | 
			
		||||
		// 默认使用go原生
 | 
			
		||||
		err := os.Setenv("GODEBUG", "netdns=go")
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			logs.Println("[DNS_RESOLVER]set env failed: " + err.Error())
 | 
			
		||||
		}
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var err error
 | 
			
		||||
	switch config.DNSResolver.Type {
 | 
			
		||||
	case nodeconfigs.DNSResolverTypeGoNative:
 | 
			
		||||
		err = os.Setenv("GODEBUG", "netdns=go")
 | 
			
		||||
	case nodeconfigs.DNSResolverTypeCGO:
 | 
			
		||||
		err = os.Setenv("GODEBUG", "netdns=cgo")
 | 
			
		||||
	default:
 | 
			
		||||
		// 默认使用go原生
 | 
			
		||||
		err = os.Setenv("GODEBUG", "netdns=go")
 | 
			
		||||
	}
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		logs.Println("[DNS_RESOLVER]set env failed: " + err.Error())
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 启动API节点
 | 
			
		||||
func (this *AdminNode) startAPINode() {
 | 
			
		||||
	var configPath = Tea.Root + "/edge-api/configs/api.yaml"
 | 
			
		||||
 
 | 
			
		||||
@@ -55,6 +55,7 @@ func (this *IndexAction) RunPost(params struct {
 | 
			
		||||
	LogoFile           *actions.File
 | 
			
		||||
	DefaultPageSize    int
 | 
			
		||||
	TimeZone           string
 | 
			
		||||
	DnsResolverType    string
 | 
			
		||||
 | 
			
		||||
	SupportModuleCDN bool
 | 
			
		||||
	SupportModuleNS  bool
 | 
			
		||||
@@ -85,6 +86,7 @@ func (this *IndexAction) RunPost(params struct {
 | 
			
		||||
	config.ShowVersion = params.ShowVersion
 | 
			
		||||
	config.Version = params.Version
 | 
			
		||||
	config.TimeZone = params.TimeZone
 | 
			
		||||
	config.DNSResolver.Type = params.DnsResolverType
 | 
			
		||||
 | 
			
		||||
	if params.DefaultPageSize > 0 {
 | 
			
		||||
		config.DefaultPageSize = params.DefaultPageSize
 | 
			
		||||
@@ -111,10 +113,10 @@ func (this *IndexAction) RunPost(params struct {
 | 
			
		||||
			this.ErrorPage(err)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		fileId := createResp.FileId
 | 
			
		||||
		var fileId = createResp.FileId
 | 
			
		||||
 | 
			
		||||
		// 上传内容
 | 
			
		||||
		buf := make([]byte, 512*1024)
 | 
			
		||||
		var buf = make([]byte, 512*1024)
 | 
			
		||||
		reader, err := params.FaviconFile.OriginFile.Open()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			this.ErrorPage(err)
 | 
			
		||||
@@ -158,10 +160,10 @@ func (this *IndexAction) RunPost(params struct {
 | 
			
		||||
			this.ErrorPage(err)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
		fileId := createResp.FileId
 | 
			
		||||
		var fileId = createResp.FileId
 | 
			
		||||
 | 
			
		||||
		// 上传内容
 | 
			
		||||
		buf := make([]byte, 512*1024)
 | 
			
		||||
		var buf = make([]byte, 512*1024)
 | 
			
		||||
		reader, err := params.LogoFile.OriginFile.Open()
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			this.ErrorPage(err)
 | 
			
		||||
 
 | 
			
		||||
@@ -109,7 +109,18 @@
 | 
			
		||||
                        </select>
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                <p class="comment">显示时间使用的时区。</p>
 | 
			
		||||
                <p class="comment">当前管理系统显示时间使用的时区。</p>
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
            <td>使用的DNS解析库</td>
 | 
			
		||||
            <td>
 | 
			
		||||
                <select class="ui dropdown auto-width" name="dnsResolverType" v-model="config.dnsResolver.type">
 | 
			
		||||
                    <option value="default">默认</option>
 | 
			
		||||
                    <option value="cgo">CGO</option>
 | 
			
		||||
                    <option value="goNative">Go原生</option>
 | 
			
		||||
                </select>
 | 
			
		||||
                <p class="comment">当前管理系统使用的DNS解析库;修改此项配置后,需要重启管理系统进程才会生效;通常不需要修改;如要修改,请在专家指导下进行。</p>
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </table>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user