Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
TCPChan is a TCP connection multiplexing library that enables working with multiple channels in a single TCP connection. TCPChan can boost the efficiency of the short-lived connections by eliminating the overhead of connection setup, especially in high-latency links (e.g. cross-continental links).
The core part of the library is decoupled from I/O libraries so it's possible to bring your own I/O library. For convenience, an Asyncio-based protocol implementation is provided for easy integration with Asyncio applications.
Warning: TCPChan is built for fun and educational purpose, it is not fully tested, and neither is it widely deployed. Use it at your own risk.
WIP
pip install tcpchan
git clone --depth 1 https://github.com/frankurcrazy/tcpchan
cd tcpchan; python setup.py install
WIP
Inherit tcpchan.core.chan.Channel
and implements data_received
callback.
from tcpchan.core.chan import Channel
class CustomChannel(Channel):
def data_received(self, data):
# Do stuff upon data reception
Create ServerConnection
or ClientConnection
instance upon connection establishment in server/client. And pass the channel factory to the Connection.
from tcpchan.core.conn import ServerConnection
conn = ServerConnection(lambda: CustomChannel())
from tcpchan.core.conn import ClientConnection
conn = ClientConnection(lambda: CustomChannel())
from tcpchan.core import (
HandshakeSuccess, DataTransmit,
ChannelCreated, ChannelClosed
)
TCPChan provides an Asyncio-based protocol implementation so that one can easily integrate TCPChan in their Asyncio applications.
For server-side application, TCPChanServerProtocol
can be used, likewise, for client-side application, TCPChanClientProtocol
can be used.
import asyncio
from tcpchan.aio import TCPChanServerProtocol
from tcpchan.core.chan import Channel
class CustomChannel(Channel):
def data_received(self, data):
# Do stuff upon data reception
...
class MyProtocol(TCPChanServerProtocol):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._channels = {} # Mapping for channels
def handshake_success(self):
# Do something on handshake success
...
def handshake_failed(self, reason):
# Do something on handshake failure
...
def channel_created(self, channel):
# Do something on channel creation
self._channels[channel.channel_id] = channel
def channel_closed(self, channel_id):
# Do something when a channel is closed
del self._channels[channel_id]
loop = asyncio.get_event_loop()
# To initialize `Protocol`, channel factory function is required.
server = await loop.create_server(
lambda: MyProtocol(lambda: CustomChannel()),
host="localhost",
port=9487,
start_serving=True,
)
loop.run_forever()
BSD
FAQs
tcpchan is a TCP (de)multiplexer
We found that tcpchan demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.