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

backend: use BackendConnMgr as ConnContext #172

Merged
merged 5 commits into from
Jan 9, 2023
Merged

Conversation

xhebox
Copy link
Collaborator

@xhebox xhebox commented Jan 5, 2023

Signed-off-by: xhe xw897002528@gmail.com

What problem does this PR solve?

Issue Number: close #174

Problem Summary: A cleanup/refactor PR for backend, proposed when thinking on how to implement compression protocol elegantly(most logic will be in Authenticator). Check #174.

What is changed and how it works:

  1. Move ctxmap and clientAddr, the core of ConnContext API into BackendConnMgr
  2. Remove supportedServerCapabilities, replaced by handshakeHandler.GetCapability()
  3. WriteInitialHandshake(), readInitialHandshake() and ParseInitialHandshake() now use pnet.Capability instead of uint32
  4. Refactor writeAuthHandshake and share common code in handshakeFirstTime and handshakeSecondTime
  5. Add WithRemoteAddr() to *PacketIO. Now PacketIO.RemoteAddr() will return the given remote addr if any.
  6. Remove clientIO.SourceAddr(), which is solely used by proxy protocol. It is now replaced by the new WithRemoteAddr()+RemoteAddr() comb.
  7. Remove BackendConn, which only has one useful method Addr(), replaced by the new WithRemoteAddr()+RemoteAddr().
  8. Remove auth.serverAddr, which is used by TLS handshake, replaced by the new WithRemoteAddr()+RemoteAddr().

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Notable changes

  • Has configuration change
  • Has HTTP API interfaces change (Don't forget to add the declarative for API)
  • Has tiproxyctl change
  • Other user behavior changes

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
@xhebox xhebox requested a review from djshow832 January 5, 2023 07:39
Comment on lines -238 to -240
host, _, err := net.SplitHostPort(inAddr)
require.NoError(t, err)
require.Equal(t, host, "::1")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I do want to keep the test, the logic of ClientAddr() moves to BackendConnMgr instead of Authenticator. Also, this test will fail on linux without IPV4. So I just removed it, maybe test BackendConnMgr more later.

pkg/proxy/backend/authenticator.go Outdated Show resolved Hide resolved
pkg/proxy/backend/backend_conn_mgr.go Outdated Show resolved Hide resolved
pkg/proxy/net/packetio.go Outdated Show resolved Hide resolved
@xhebox xhebox requested a review from djshow832 January 6, 2023 10:06
Signed-off-by: xhe <xw897002528@gmail.com>
@djshow832 djshow832 merged commit 483af7d into pingcap:main Jan 9, 2023
@xhebox xhebox deleted the tcp_5 branch March 7, 2023 03:18
xhebox added a commit to xhebox/TiProxy that referenced this pull request Mar 7, 2023
xhebox added a commit to xhebox/TiProxy that referenced this pull request Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: use BackendConnMgr as ConnContext
2 participants