killme2008 / killme2008/xmemcached

当使用的别名不是hosts内绑定的第一个时带auth请求失败

Open
#104 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
764
Forks
271
PR merge metrics
No merged PRs in 30d

Description

```
String ip = "";
int port = 11211;
String user = "cacheuser";
String password = "12345";
InetSocketAddress inetSocketAddress = new InetSocketAddress(ip, port);
XMemcachedClientBuilder memcachedClientBuilder = new XMemcachedClientBuilder(Arrays.asList(inetSocketAddress));
memcachedClientBuilder.setConnectionPoolSize(3);
memcachedClientBuilder.setCommandFactory(new BinaryCommandFactory());
memcachedClientBuilder.setAuthInfoMap(Collections.singletonMap(inetSocketAddress, AuthInfo.plain(user, password)));
MemcachedClient memcachedClient = memcachedClientBuilder.build();
memcachedClient.set("aaa", 86400, "12345");
String a2 = memcachedClient.get("aaa");
System.out.println(a2);
```

- 当hosts内存在

`192.168.1.5 cache1`

代码``直接使用使用ip:`192.168.1.5`时会验证失败,使用`cache1`正常

- 当hosts内存在

```
192.168.1.5 cache1
192.168.1.5 cache2
```
代码``使用别名: `cache2`会验证失败,使用`cache1`正常

---
出错代码 [AuthMemcachedConnectListener](https://github.com/killme2008/xmemcached/blob/1f48c70eb575109f1874ace72b1462f018d3e01d/src/main/java/net/rubyeye/xmemcached/auth/AuthMemcachedConnectListener.java)
内的
```
AuthInfo authInfo =
authInfoMap.get(AddrUtil.getServerString(tcpSession.getRemoteSocketAddress()));
```
取到null

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/main/java/net/rubyeye/xmemcached/auth/AuthMemcachedConnectListener.java, especially the AuthInfo lookup shown in the issue. Reproduce the example using an IP and multiple hosts-file aliases, then trace how the remote socket address is converted for authentication. Done means authenticated requests succeed for the IP and every configured alias.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, memcached
Domain
authentication, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.