Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

篡改自定义nacos注册信息 #1348

Open
LiangQinghai opened this issue May 15, 2024 · 3 comments
Open

篡改自定义nacos注册信息 #1348

LiangQinghai opened this issue May 15, 2024 · 3 comments

Comments

@LiangQinghai
Copy link

Describe the bug

无法指定服务注册ip信息

To Reproduce

Steps to reproduce the behavior:

  1. 服务注册中心选择nacos,
  2. 本地电脑运行,
  3. 通过server.WithRegistryInfo设置了绑定注册ip到127.0.0.1,
  4. 通过server.WithServiceAddr(addr)绑定了服务的运行ip是0.0.0.0

Expected behavior

期望nacos注册的ip地址是127.0.0.1

Screenshots

github.com/cloudwego/kitex@v0.9.1/server/server.go:265 在Run方法调用了buildRegistryInfo方法对注册信息进行了修改,修改为当前服务运行的地址

func (s *server) buildRegistryInfo(lAddr net.Addr) {
	if s.opt.RegistryInfo == nil {
		s.opt.RegistryInfo = &registry.Info{}
	}
	info := s.opt.RegistryInfo
	// notice: lAddr may be nil when listen failed
	info.Addr = lAddr
	if info.ServiceName == "" {
		info.ServiceName = s.opt.Svr.ServiceName
	}
	if info.PayloadCodec == "" {
		info.PayloadCodec = getDefaultSvcInfo(s.svcs).PayloadCodec.String()
	}
	if info.Weight == 0 {
		info.Weight = discovery.DefaultWeight
	}
	if info.Tags == nil {
		info.Tags = s.opt.Svr.Tags
	}
}

运行时截图

image
image

Kitex version:

0.9.1

Environment:

windows

@LiangQinghai
Copy link
Author

image
这个是注册到nacos的地址

当我把服务运行的地址绑定到127.0.0.1的时候就可以正确注册127.0.0.1到nacos

@felix021
Copy link
Contributor

felix021 commented May 15, 2024

这个问题在develop 分支修了,详见 #1329

我们可能会在本月发布一个新版本,急用的话可以先用 v0.9.3-rc2

@felix021
Copy link
Contributor

担心稳定性的话,也可以参考 https://github.com/kitex-contrib/registry-etcd/pull/32/files 的做法,自己fork 个 registry-nacos 先应急

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants