lipp / lipp/lua-websockets

Make client socket accessible?

Open
#83 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
419
Forks
117
PR merge metrics
No merged PRs in 30d

Description

In an application using `websocket.server.copas`, i need to access some information from the socket: IP address and port. They can be obtained using luasocket's `getpeername ()`. This method is hidden by `copas` (but can be worked around using `sock.socket`).

A very simple hack is to add a field containing the socket inside the `ws` object passed to the handler, as in this commit: d6c32fbdd51dd16f955392ca6575f42f4a838f45. But you may also want a more general solution available also in `websocket.server.ev` and in clients.

Maybe i just missed an already existing solution?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the websocket.server.copas handler and inspect how the ws object hides the underlying socket, including the existing sock.socket workaround and LuaSocket getpeername(). Compare this with websocket.server.ev and client handling, then define a consistent way for handlers or clients to access socket information and verify it across those paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.