#networks

1 messages · Page 45 of 1

cloud spruce
#

if you look at all the networks on the map you'll see that you have (in numeric order):
192.168.2.0/27 taking up 192.168.2.0 - 192.168.2.31 connected to eth1 on R01
192.168.2.32/27 taking up 192.168.2.32 - 192.168.2.63 connected to eth1 on R02
192.168.2.64/26 taking up 192.168.2.64 - 192.168.2.127 connected to eth3 on R03
192.168.2.128/26 taking up 192.168.2.128 - 192.168.2.191 connected to eth2 on R03
192.168.2.192/26 which would take up 192.168.2.192 - 192.168.2.255 doesn't look like it's being used and would then be free address space, this could be network A
192.168.3.0/25 taking up 192.168.3.0 - 192.168.3.127 connected to eth0 on R05
192.168.3.128/25taking up 192.168.3.128 - 192.168.3.255 connected to eth0 on R06
and everything fits neatly in a 192.168.2.0/23 prefix with would mean 192.168.2.0 - 192.168.3.255

#

it wouldn't be 10.0.0.22/30 as a prefix address there as prefix addresses should generally have the base network address written out not any other ip address contained within the prefix
and as image says that the interface address of eth0 on R01 is 10.0.0.21 (which can be annotated as 10.0.0.21/30 if one wants to include the prefix length with the interface address, but you wouldn't write it like that if it's a network prefix) and your instructions says that the link networks should all be /30 it must be 10.0.0.20/30 which includes 10.0.0.20 - 10.0.0.23 where the first address is the network address and the last is the broadcast address, this leaves us with two usable host addresses on that network 10.0.0.21 and 10.0.0.22

sacred isle
#

There's this other case. I get the 192.168.2 but not the rest, the .0/24

#

Specially the mask part /24, how come that /24 is the one and not /23 or /25?

cloud spruce
sacred isle
#

and using 192.168.2.0/24 is the maximum length?

#

And the last question, if that's not right, but /26, why not use a smaller mask?

cloud spruce
cloud spruce
sacred isle
sacred isle
cloud spruce
#

any more questions on this or anything else related?
otherwise i'll just wish you all the best on the exam

sacred isle
#

Though if you don't have time that's okay, you already helped me a lot

cloud spruce
cloud spruce
sacred isle
#

Oh wait it does makes sense that is wrong! I see that the IP I uses there should have been the one of the router network

sacred isle
#

That's the only remaining doubt now

cloud spruce
cloud spruce
# sacred isle What I forgot about the previous attempt was is the difference of R01 eth1 and R...

eth1 and eth2 on R01 are just the same, no difference at all
they just want you to figure out for your self what the prefix of the network that they have only named A should be and they also gave you a clue that it's something within the 192.168.2.0/24 summarization (sometimes also called a supernet)
in #networks message i gave you clues how you would go about finding out which network A would be by the process of deduction and elimination, by excluding all other possibilities as they where already in use and finding the unused address space that is not used anywhere else in the network within the bounds of the address space that is otherwise used for the network

sacred isle
#

Now I do get it!

cloud spruce
# sacred isle Ohh so what they give is not A's address!

they want you to figure out what prefix should go there instead of the placeholder A, in this case 192.168.2.192/26 as that was the gaping hole in the address plan after we had listed all other addresses used in the address plan for this whole network

civic dagger
#

i made a networking app

#

and I need someone to try it

cloud spruce
light zealot
#

@cloud spruce is it possible to do group chat in p2p?

#

like I've a setup wherein one client can wait for another client to connect to it and then they both can chat

#

it's just a one on one chat

#

I was wondering if it's really possible to do group chat

#

I can't think of a way

ember ledge
#

I have an old phone. Any projects I could do with it? Any ideas?

cloud spruce
# light zealot I can't think of a way

it's possible, but then every client must connect to every other client in the group and send the same message to everyone that should receive it in the group, at least if you want it to be truly p2p and not let clients relay messages to each other

light zealot
#

I never knew that

cloud spruce
# light zealot is it possible to do `sock.connect()` multiple times?

you can, but you need to store all the sockets in a list of something like that and then check all the sockets for data using something like select() or other interface that might be better on the platform you are targeting (select() works good on linux, bsd, macos and other *nix like platforms, but it's not the best for windows even if it will mostly works there too)
or you might want too look into using asyncio instead which might be a better option for you even if it's more advanced to use

cloud spruce
#

!rule 9 probably applies here

errant bayBOT
#

9. Do not offer or ask for paid work of any kind.

civic dagger
#

dude, I learned to print("Hello, World!") like 4 days ago

cloud spruce
# civic dagger so you think a noob like me can grab your public ip and do very bad things with ...

someone that wants to do bad things can play what ever role they think will serve them best to achieve there goals, playing a noob, it-support, person with some kind of authority or what ever
social engineering is the oldest trick in the book and probably the most successful one too 😉
also, if you trick someone into running bad code on their computer you don't even need to know the public ip address to their computer to screw it up, and getting their public ip address and even a reverse tunnel into that persons computer would also be trivial in such a situation
that's why i won't run code from someone i "meet" that they wants me to run/try without first studying and understanding the source code, that's also my recommendation to everyone else if they ant to stay safe online

light zealot
#

someone deleted my message...?

#

nvm I'll ask again

#

Say I've a list of lists of some ips and ports
[ [ip1,port,1], [ip2,port2], ...]
How would I go on to broadcast a message to all of them?

cloud spruce
# light zealot nvm I'll ask again

see too it that you have sockets connected to each peer, you can store the sockets in another list or other data structure, then you loop through the list of sockets and send the message to each peer

cloud spruce
light zealot
#

makes sense

#

thanks

zealous flint
#

But like mentioned a threat actor can use whatever method they feel is best to exploit you

civic dagger
civic dagger
zealous flint
#

I wouldn’t

#

Don’t know how legal it is in different places

#

Also routers and ISPs have become pretty good at filtering obvious DoS traffic out

ember ledge
#

@civic dagger if your target has some interesting NAT configurations and ports open you might be able to get into a network and hack it from there

#

though most of the time you won't see a telnet port forwarding rule in the wild so it's not that easy

opaque gulch
#

how do I make changes in resolv.conf permanent on ubuntu 22.04 ?

#

I tried like this

#

by changing in the head file located in /etc/resolvconf/resolv.conf.d/head but it didn't apply changes when I restarted the vm

analog compass
#

i wanna make a proxy, how do i view all outgoing requests from my local computer?

livid ore
#

Does anyone has a good solution how I can connect to 2 Socket Servers at the same time with SocketIO maybe with different asyncio tasks ?

agile stream
#

I have a gunicorn which I am running on Pycharm, but I cannot get the logging.info() to print out to the pycharm console (not working on Terminal too). I added those extra flags backend.gunicorn:application --log-level debug --capture-output --access-logfile - --error-logfile - (this is the whole script), but still it refuses to print out stuff

#

However, print("sstatement") prints to the console though.

unborn pilot
#

you know how many public wifi's have a click to accept page and you connect to the internet? what if i wanted to make one of those for myself? how would i go about doing that/what do i google?

trim wedge
#

i wanted to send a list from client to server by services in ros, and faced a problem A file is auto generated by ros, and the file has a problem by default and gives me this error:struct error: the required argument is not a float.

this is the line whcih has error: buff.write(_get_struct_2f().pack(_x.coef_list, _x.bounds))

unborn pilot
#

ah yes ty recursive

opaque gulch
#

does a switch need to have a static ip ?

white basalt
#

in a TCP connection they have the data packets of; ethernet frame, IP datagram, TCP protocol. But what about a UDP conection does it have only ethernet frame, IP datagram only?

twin thicket
#

Hey all, just to touch base. im unsure if this is the right room for tools for CTF. Im trying to write a bruteforce login creds, how to I make sure that my socket connection is connected to the web domain im trying to brute force? If anyone could give me some tips or someone has already made on would be good 🙂 to see how you guys and gals did it

cloud spruce
# opaque gulch does a switch need to have a static ip ?

a switch don't need an ip address to do [L2] switching
if it's a managed switch you can will need an ip address on it to reach it if you are going to manage it over the network and not just via the a serial console or similar, but that ip address can live on another network such as an out of band management network
if the switch is a L3 switch and can do [L3] routing as well as [L2] switching it's essentially a router as well and will need at least an ip address on each network that it should be able to route traffic to and from

cloud spruce
cloud spruce
errant bayBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

twin thicket
#

Oh okay

cloud spruce
#

we would probably need to see at least the relevant bits of your code to be able to help you with that

cloud spruce
#

aha, you can't be sure the client will send the whole username or password in one single packet
so you can't just do one read and then move on, you need to loop for each response that you are expecting and search for a line break of some kind in the string before you move on
i would suggest making that a function for you too call each time you need to read a line from the socket
also, if you have it like you do right now with the accept() in one client connecting will prohibit any other clients connecting while it's processing that client
you essentially can only serve one client at a time that will block any further clients from connecting to the server

cloud spruce
#

it's not bits, it's 1024 bytes and it will not wait for that many bytes
and it's not how recv() works, it will return up to 1024 bytes but it may also return just one bytes
in other words, you still need to loop and wait for a line break character of some kind before moving on in the code

#

yeah, the telnet client probably has remote echo turned on, so it will send each character to the server as it's being typed not waiting for a line break, and recv() will return that data as soon as it receives it

#

no problem
i hope you know that telnet and other such unencrypted protocols aren't secure and whom ever can intercept the traffic will see everything that is transmitted between the two peers

cloud spruce
#

as long as you are aware and don't use it for anything "real" and more for learning, otherwise you probably want to wrap it in TLS or something (but then a telnet client will not be compatible with your service)
because even if it's not used for something important people unfortunately tend to reuse passwords which could jeopardize accounts on other services they use if the password would leak over this service

cloud spruce
ember ledge
#

Hey! I just got an hoster and when i wanted to start it it said this: See screenshot

In short; It couldnt ping...

How can i fix this?

cloud spruce
loud socket
#

heyy, is there something like the socket module but online ?

earnest blaze
#

Wdym by but online, it is online.

loud socket
#

Not on the same network

#

like me and another machine

#

like ssh

earnest blaze
loud socket
earnest blaze
#

No, just redirect the designated traffic to the machine hosting the server via port forwarding.

wicked wren
#

are bssid and mac addr of a router the same thing?

opaque gulch
#

Could anyone help me with GNS3 please, I have this lab screenshot I need to replicate.

#

i really do not know how though

ember ledge
#

how do I send files or folders from sockets?

fair kindle
#

!pypi pysendfile also might be worth looking into

errant bayBOT
jade viper
#

Hello fellow programmers. I'm working on a project with a simple HTML form that uploads a file, like so:

<HTML>
    <BODY>
        <form action="upload" method="POST" enctype="multipart/form-data">
            <input type="file" id="upload" name="upload">
            <input type="submit" value="Upload">
        </form>
    </BODY>
</HTML>

I want to emulate this with aiohttp, but I can't figure out how it's supposed to work.
https://docs.aiohttp.org/en/stable/multipart.html
This should be the multipart documentation, but it looks really complex for what I need.

    async def accept_upload(self, req):
        with open(_TMPFILE_NAME, "wb") as f:
            post = await req.post()
            f.write(post.get("upload").file.read())

        self._job_handler.queue(_TMPFILE_NAME)

        return web.Response(status=200)

The upload endpoints looks like this, and doesn't require this fancy-schmancy multipart reader stuff. I ought to be able to write in a similar, simple fashion.

#

Anyone know what's going on and how I can fix it?

#

Looks like accepting the upload doesn't work quite right either, because post.get("upload") returns a bytearray object.

#

So I don't exactly have no idea what I'm doing... but I have no idea what I'm doing. 😂
I'm quite lost here despite having nice documentation. 😂

#

The code for the upload endpoint was partly copied from some part of the official aiohttp tutorial IIRC, with modifications that I made probably.

jade viper
#

So, uh, as usually happens when I post a question here, I've fixed it. 😐

#

So I'll change this from a "help IDK what I'm doing" to a "I did something but did I do it well?" question

#
async def test_server_writes_request_body_to_file():
    mock_handler = Mock()
    app = init_app(mock_handler)
    async with TestClient(TestServer(app)) as client:
        with aiohttp.MultipartWriter("form-data") as mpwriter:
            mpwriter.append(io.BytesIO(b"yay"), {"name" : "upload", aiohttp.hdrs.CONTENT_TYPE : "application/octet-stream"})
            await client.post("/upload", data=mpwriter)
    _, args, _ = mock_handler.mock_calls[0]
    with open(args[0], "rb") as f:
        assert f.read() == b"yay"
#

Got my test.

#
    async def accept_upload(self, req):
        print(req.content_type)
        reader = await req.multipart()
        filedata = await (await reader.next()).read()
        with open(_TMPFILE_NAME, "wb") as f:
            f.write(filedata)

        self._job_handler.queue(_TMPFILE_NAME)

        return web.Response(status=200)
#

And my handler.

#

HTML form is unchanged.

cloud spruce
jade viper
opaque gulch
#

what should be the number after the / for a range of 190 starting at 172.16.0.10/?

brisk orchid
cloud spruce
ember ledge
errant bayBOT
loud socket
#

ty

gloomy crest
#

Hiya folks,
If I know my friend’s IP, I can connect to his server which he’ll be running when using sockets, right?
Is there any limit to such action? (For example distance / anything else)?

ember ledge
cloud spruce
# gloomy crest Hiya folks, If I know my friend’s IP, I can connect to his server which he’ll be...

it must be a public ip address, not a private ip address that is just available on your friends network
if your friend want to run the socket server on a computer on a private ip address they must first configure their router/firewall to port forward traffic from the public ip address on that device to the machine running the socket server
if there is a firewall in the path (or on the machine) it can stop the connection unless configured to allow that traffic through

gloomy crest
#

Thanks peeps 👍

raw coyote
#

Hey! I'm trying to make a chat server. I need multiple users connected simultaneusly so i've been looking into threading each client. Problem is when i call socket.recv(16) on the client, i get error the following error:
OSError: [WinError 10038] An operation was attempted on something that is not a socket
Can anyone help?

import socket
import threading

PORT = 13031

class ClientThread(threading.Thread):
    def __init__(self, socket, addr):
        threading.Thread.__init__(self)
        self.socket = socket
        self.addr = addr
        print("New connection added: " + str(addr))

    def run(self):
        print("Connection from: " + str(addr))
        while(True):
            print(self.socket)
            msg = self.socket.recv(16) # Error 10038 on client connect
            print(msg)

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the port
serverAddr = ('localhost', PORT)
print('starting up on %s port %s' % serverAddr)
sock.bind(serverAddr)

# Listen for incoming connections
sock.listen(1)

while True:
    # Wait for a connection
    print('waiting for a connection') 
    conn, addr = sock.accept()
    try:
        newClient = ClientThread(conn, addr)
        newClient.start()
    finally:
        conn.close()```
cloud spruce
# raw coyote Hey! I'm trying to make a chat server. I need multiple users connected simultane...

the call to conn.close() within the finally block will run in the main thread before you even have a chance to do the .recv() on the socket in the client thread, this is what is cause that problem
16 bytes is a bit small for a .recv(), consider using at least 1472 bytes or more to be able to gobble up the payload of one full tcp/ip packet on a standard network

i would suggest using asyncio instead of threads in such use cases if you need to scale the solution to many clients
but it will involve more new concepts to wrap your head around working with async/await if you haven't done that before
there is however the channel #async-and-concurrency for such things (including threading if you want to stay with that but still need any help in that department)

raw coyote
#

@cloud spruce That's it! Thanks! I'll look into the asyncio thing.
I am aware the recv is short, i have more code to deal with message lengths, just omitted it because it wasn't important for this issue.

One more issue, one i was dealing with before switching to threads. When the server is waiting for .recv(); if the client disconnects abruptly, .recv() will throw an error and basically kill the server. Is there a better solution to this than wrapping it in try-except?
The error:

ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host```
#

I am aware that the client can help perform a graceful disconnect, but i can't trust that it will happen every time

cloud spruce
raw coyote
#

@cloud sprucealright, thanks again! I did some reading about asyncio and i can see why it's preferable.

cloud spruce
fleet canyon
#

hey

#

how are you

#

i

#

am

#

fine

#

thx

#

just tring to hit

#

50

#

msg

#

so i

#

can

#

chat

cloud spruce
errant bayBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

fleet canyon
clever jackal
#

Why does only 1 client connect and not 2?

Server:

#new code

from re import T
import socket
import threading
import time

clients = set()
clients_lock = threading.Lock()

HOST = '127.0.0.1'
PORT = 9090


def acceptclient():
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    s.bind((HOST, PORT))
    s.listen(5)
    con,addr=s.accept()
    print(f"Connected to {addr} adress.")
    con.send("You are now connected to the server.".encode("utf-8"))
    with clients_lock:
        clients.add(con)
    try:
        while True:
            data = con.recv(1024)
            if not data:
                break
            else:
                #print(data.decode("utf-8"))
                with clients_lock:
                    for c in clients.copy():
                        c.sendall(data)
                        #con.close()
                        #clients.remove(con)
    finally:
        print(f"Disconnected {con}.")

while True:
    acceptclient()

Client:

import socket
import time

HOST = '127.0.0.1'
PORT = 9090

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.connect((HOST, PORT))

while True:
    data = s.recv(1024)
    if not data: break
    data = data.decode('utf-8')
    print(f'{data}')
    time.sleep(1)
    inputs = input("Your Message:")
    s.send(inputs.encode("utf-8"))
cloud spruce
ember ledge
errant bayBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

worthy widget
#

Y'all I need some help. I am a coach for a robotics team at a school and we need to setup a network. We can't use the schools network because it is so locked down. We can run our network just fine but when we plug our router into the Ethernet of the school, the schools admin gets in a pissy fit because he gets a notification there is a rouge DHCP server. Which is technically true but no devices outside of our network ever connect to our router and we aren't trying to man in the middle our own devices... It's also on Saturday so it's not like anyone else is trying to use the network anyways

#

What am I supposed to say to him lol

#

He's also IT support for a high school with a "degree in windows and worked in geek squad for 10 years" so there's that

clever jackal
#

Is there a way to print stuff when input is active? (by input i mean Input = input("Your message: "))

Server:

import socket
import os
from _thread import *
import threading
clients = set()
clients_lock = threading.Lock()
ServerSideSocket = socket.socket()
host = '127.0.0.1'
port = 2004
ThreadCount = 0
try:
    ServerSideSocket.bind((host, port))
except socket.error as e:
    print(str(e))
print('Socket is listening..')
ServerSideSocket.listen(5)
def multi_threaded_client(connection):
    connection.send(str.encode('Server is working:'))
    with clients_lock:
        clients.add(connection)
    while True:
        data = connection.recv(1024)
        if not data: 
            break
        with clients_lock:
            for c in clients.copy():
                #print(c)
                c.sendall(data)
                print("SENT")
while True:
    Client, address = ServerSideSocket.accept()
    print('Connected to: ' + address[0] + ':' + str(address[1]))
    start_new_thread(multi_threaded_client, (Client, ))
    ThreadCount += 1
    print('Thread Number: ' + str(ThreadCount))
ServerSideSocket.close()

Client:

import socket
ClientMultiSocket = socket.socket()
host = '127.0.0.1'
port = 2004
print('Waiting for connection response')
try:
    ClientMultiSocket.connect((host, port))
except socket.error as e:
    print(str(e))
res = ClientMultiSocket.recv(1024)
while True:
    Input = input('Message: ')
    ClientMultiSocket.send(str.encode(Input))
    res = ClientMultiSocket.recv(1024)
    print(res.decode('utf-8'))
ClientMultiSocket.close()

Multiple connection is managed by server.

cloud spruce
# clever jackal Is there a way to print stuff when input is active? (by input i mean `Input = in...

input() is a blocking call and you're not using any kind of concurrency (asyncio, threads or multi-process) so your program can't do anything else while waiting for the input to finish

even if it did it would probably get messy as you are only using stdin and stdout in a terminal kind of environment
what would happen if the user of the client is in the middle of a sentence or a word when data comes in from the server and immediately gets printed where the cursor is currently positioned?
to fix that you would need something like a gui or ncursors if you stick to a terminal and some kind of event loop

cloud spruce
# worthy widget Y'all I need some help. I am a coach for a robotics team at a school and we need...

the router should typically not have the DHCP server running on its outside interface connected to the upstream network and everything should be fine

or if you have connected the router to the network using one of the switched ports its only acting as a switch and you should simply be able to turn off the DHCP server in your router and the clints on your router should get their ip addresses from the schools DHCP server instead

if the school network has proper network equipment that was properly configured this wouldn't be an issue at all since it would guard against a rouge DHCP server from even being able to affect the network at all using something like DHCP snooping, but at least they have some kind of alert warning them about it, so that's at least something, feels like it's just half way implemented though

a rouge DHCP server can have lingering consequences for devices on the network even after it has been disconnected from the network and make the affected devices use the wrong ip space which would make them unable to talk to anything else on the network that isn't adversely affected in the same way, especially not being able to talk to the gateway and connect to anything outside of the local subnet, and how long those problems last will be determined by the lease timers controlled by the rouge DHCP server or until the device is rebooted after the rouge DHCP server is off the network again

wispy jackal
worthy widget
# cloud spruce the router should typically not have the DHCP server running on its outside inte...

Thanks I appreciate your response. We can't use the switching option because they have stupid thick security so we can't ssh or set device side static ips. It's also not running outside it's interface and we have never gotten a rogue device connected to the router verified by logs. We connected it to the schools router by the wan port which shouldnt be switched but I can check the router page.

And no, this guy is a high school IT support. The network isnt properly configured. He told us if we didn't stop he would "stop us" but by "stop us" he meant he would just disable all the Ethernet ports for good

#

Also our lease timers are 10 minutes and we're not trying to DHCP snoop either so there's that

cloud spruce
# worthy widget Thanks I appreciate your response. We can't use the switching option because the...

you are using a normal home router and connecting its wan interface to the school's network, right?

i meant the wan interface when I said outside interface, it's really strange that your router is acting as a DHCP server on the wan interface, that is very unusual and you should try to turn the DHCP server off from that interface if it's really on, usually the wan interface of a home router would instead act as a DHCP client and ask the network for an ip address to use

you shouldn't need to set any static ip addresses or do you require them to be static for your project?
if you do need to use static ip addresses it should be fine behind the home router if you use NAT on the router just like it would be setup if you ran it at home between the internet and your home network

and what is this about ssh?
you shouldn't need ssh, and if you do need it for your project it should still work within the network you create behind the home router

cloud spruce
# worthy widget Also our lease timers are 10 minutes and we're not trying to DHCP snoop either s...

it's good that you keep the lease timers low for now so that there is less risk of you inadvertently create a problem on the school network as their network doesn't seem to protect against that enough

no, DHCP snooping doesn't have anything to do with you sniffing or doing anything malicious (and i'm not saying/suggesting that you are)
DHCP snooping is the name of the security feature in many managed switches like the ones your school probably have, it configures the switch to detect DHCP traffic from non-authorized DHCP servers on the network and block that traffic so that they can't create a problem on the network in the first place

rigid wing
#

does someone have a python script that will proxy all traffic that gets connected to it, to an appropriate endpoint (the endpoint the client tries to get to)? the smaller the better

wispy jackal
rigid wing
wispy jackal
#

I had written a toy proxy that used Twisted to provide an MTLS termination for internal services at DeBeers. But I've not written a multi-protocol solution in python before.
Is it all HTTP? and TCP?

rigid wing
#

technically I'd only need to support TCP, although having support for both would be ideal. I started with just making HTTP support, but couldn't get it to work

#

I want to connect it up to my phone to MITM certain things, and ideally I wouldn't break everything else whilst doing so

wispy jackal
#

So raw TCP should be fairly simple and support http too, so long as you don't want it to intercept HTTPS or TLS

#

If you want to handle encrypted traffic then you need to look at protocols like SOCKS... but this doesn't really give you a lot of access to any of the data that passes through.

#

An alternative might be to use Burp Suite and then parse the stream feed

#

Burp Suite is a pretty complete solution, and gives a lot of access to the data that it proxies without significant effort

rigid wing
#

don't remember if it's using HTTPS, currently I'm using windivert to proxy to intercept and modify packets, but it's very slow and also effects the entire network flow on my PC and can slow down the network a lot.

As for Burp Suite, it looks like it would be over kill for my system at first glance. If I could get a basic HTTP protocol working I could probably figure out the rest of the hoops myself

ember ledge
#

looking for people that know hdml

wispy jackal
rigid wing
#

would really prefer not using a library, but I will check it out. Thanks

wispy jackal
#

Twisted's documentation is a little shit, but it's the best option. Doing it in pure python from scratch is going to be a bit too heavy

rigid wing
#

Yeah will check it out, is it possible to see which 3rd party libraries it requires?

wispy jackal
#

If you're still struggling on Monday, I could help when I'm streaming

#

Twisted doesn't have any external dependencies IIRC

rigid wing
#

if it doesn't then it should be fine OK

wispy jackal
rigid wing
#

looks like it adds a couple, but doesn't seem to be too many

#

will try to make a implementation tomorrow, thanks

wispy jackal
#

ahh okay it's added a few since I last looked

#
    zope.interface >= 4.4.2
    constantly >= 15.1
    incremental >= 21.3.0
    Automat >= 0.8.0
    hyperlink >= 17.1.1
    attrs >= 19.2.0
    typing_extensions >= 3.6.5
    twisted-iocpsupport >= 1.0.2, <2; platform_system == "Windows"```
#

@rigid wing Sure, have a go with twisted I think you should be able to get it done pretty easily (although I admit the documentation sucks a little).
If you get stuck I'll be streaming on twitch (https://twitch.tv/plaintextnerds) on Monday from 10:30 (UTC+1 / BST), I'll be happy to answer any questions and help you debug / write it. I have an open-door policy on my stream so provided I'm not working on a client project you're welcome to ask for debugging and network coding help.

Twitch

(He/Him) Tim is a Staff / Lead Engineer that specializes in networking and real-time technologies but has a growing passion for games and video streaming. Each month he spends 2 weeks working on GeoIP.Network, and the rest of the time Writing.

▶ Play video
#

Feel free to drop in any-time and I'll be happy to help

#

The only exceptions are as I said, if I'm working on a client project, or already helping someone

rigid wing
#

Sounds good, thanks Salute

wispy jackal
steady horizon
#

I want an explanation about peer to peer. Specially why is it preferred at all (except maybe for direct messages)

cloud spruce
#

multi-player games and chats usually go through a server and not directly between participants, this also maintains users relative anonymity and protects users against others finding out their public ip addresses which can give away information about a possible rough location amongst other things as well as open up possibilities to attack each other, mainly with different kind of DoS attacks

peer-to-peer mainly has a usage when there are very large data transfers that you don't want to burden the server with but comes with challenges when both parties are behind different NATs

you can often overcome those challenges using techniques such as STUN, ICE and TURN, often involving a third-party (not behind a NAT) to use for the initial information exchange needed between the two parties that is each situated behind different NATs that want to communicate with each other
https://en.wikipedia.org/wiki/STUN
https://en.wikipedia.org/wiki/Interactive_Connectivity_Establishment
https://en.wikipedia.org/wiki/Traversal_Using_Relays_around_NAT

wispy jackal
#

@ember ledge as @cloud spruce says P2P is not something commonly used in NetCode for games, it almost always goes via a gameserver. This is partly due to the pragmatic simplicity (vs trying to orchestrate p2p state consensus - See RAFT protocol for more info), but also because Eyeball Networks (home and office ISPs) tend to have shitty peering and transit management leading to asymmetry in latency, jitter, and packet loss.

#

It might be used for reducing the load on servers w.r.t DLC distribution, but in these situations it's little more than Bittorrent.

#

If you want to look into building a gameserver manually (rather than using something like proton), then you'll need a good grasp on UDP wire-protocols, Pub-Sub architectures, statistical analysis (for cheat detection), and UDP reflection attacks (or more specifically, how to prevent them).

#

Python is not an ideal language for any of these as you have a <5 msec response window per client update. That's not to say it's impossible, you can do it, but it's harder than it needs to be and you end up using CTypes, and a bunch of bit-wise operations.

#

A common language choice for this C# as it has high-performance built-in binary marshalling and un-marshalling. I've worked on C++ based game servers too which isn't too painful, provided that you can keep the protocol simple enough to use PODS (Plain-Old Data Structs), but if you start messing with the packing and/or Endiannes, then it can get messy.

worthy widget
# cloud spruce you are using a normal home router and connecting its wan interface to the schoo...

Yeah we need ssh and static ips for our project. Which is why we can't just use the school network as they don't allow us to communicate between devices. We have our internal network setup how we need it and yeah we're using some random home router. That being said, I still don't know how it would be a rogue DHCP server when we have never had a connection by a device outside of the network...

I'm kinda at a loss for what to do... This guy also communicates through a student who runs track? and doesn't ever talk to the coaches directly and his solution if we don't "stop" is to just shut off the network on the weekends lmao

The conclusion that the coaches have come up with is that he is just trying to be self important and there's not an actual issue and it's nice to know that so far that is a correct assessment

cloud spruce
# worthy widget Yeah we need ssh and static ips for our project. Which is why we can't just use ...

okay, got it, then i see why you would need static ip addresses and ssh access within your own little network that you have created on the inside of the home router, and this setup should allow for that

the terminology "rogue DHCP server" just mean a DHCP server that shouldn't be on the network as they can negatively affect the network
it got nothing to do with anyone else connecting to the network from outside

as long as your home router is connected to the school network with the WAN interface and the router is setup as it typically is for home usage, where the router will act as a DHCP client (not a server) on the WAN side and just run the DHCP server only on the LAN side, you should be fine
just see to it that your home router is set up to act as a router/firewall and not a switch between the WAN and the LAN side and will apply source NAT to the traffic from the inside network which traverses the router to hide the inside ip addresses with its own ip address that it got from the school network

worthy widget
#

My point to the outside devices thing was if our server was actually serving DHCP addresses, then other devices should be connecting to it right?

cloud spruce
worthy widget
#

I mean it works

#

It's just this guy complaining about it

#

We never have any technical problems especially because they use 10.0.0 and we use 192.168.1

cloud spruce
# worthy widget My point to the outside devices thing was if our server was actually serving DHC...

if your home router was acting as a DHCP server on the WAN interface (which it shouldn't) and affecting other devices on the school network (which i really hope that it isn't, that would be bad, hopefully the switches on school network are properly setup with DHCP snooping to protect against that) they probably wouldn't find their way to your router because the ip addresses that it would give out would be for the LAN side (inside) of the home router which those devices wouldn't know how to reach and thous would not be able to even try to connect to your router

stuck wyvern
#

when are messages sent via tcp/ip broken up into packets? I looked at http://web.stanford.edu/class/msande91si/www-spr04/readings/week1/InternetWhitepaper.htm# and it says that each layer breaks messages into packets, whereas at https://www.bbc.co.uk/bitesize/guides/zj88jty/revision/7 and most other websites say that messages are split into packets at the transport layer.

worthy widget
cloud spruce
cloud spruce
cloud spruce
stuck wyvern
cloud spruce
stuck wyvern
cloud spruce
# stuck wyvern I was taught in school and read on the internet that the TCP/IP protocol only ha...

the whole iso model has 7 layers, but TCP/IP stops at the 4:th layer (TCP belongs to layer 4 and IP belongs to layer 3), then there are usually other protocols on top of TCP making up the last 3 layers (layer 5 through 7)
many times this theoretical model is not really how it works in the real world and there isn't always such a clear cut way to separate what is going on on top of TCP into all of those layers other layers

stuck wyvern
#

okayyy, thanks for the explanation

cloud spruce
hardy anvil
#

When I send a set of bytes from a client to a server via socket, do those bytes also include the TCP/IP bytes, or strictly just whatever else I am wanting to send to the server?

I ask because I'm trying to measure the amount of total bandwidth used when sending an image. I tried using net_io_counters().bytes_recv from psutil but I don't think it's exclusive to just what is being sent over a socket

worthy widget
cloud spruce
worthy widget
#

I mean idk the network isn't really set up that well so

spare vessel
#

but it's more than likely the header overhead is negligible to the actual payload, unless the connection is very unstable and has a lot of retransmission

earnest blaze
# hardy anvil When I send a set of bytes from a client to a server via socket, do those bytes ...

When I send a set of bytes from a client to a server via socket, do those bytes also include the TCP/IP bytes, or strictly just whatever else I am wanting to send to the server?
The former of course. If you just threw your data how is it supposed to arrive anywhere with no headers?
I ask because I'm trying to measure the amount of total bandwidth used when sending an image.
The tcp/ip header is 40 bytes.
Even if you don't use packets efficiently and keep sending them out before an MSS worth of data is buffered, the overhead will be negligable, and pratically non-existant if they're used efficiently.

sage ibex
#

yes

wispy talon
#

!pypi pygame

errant bayBOT
lean jacinth
#

!or

errant bayBOT
#

When checking if something is equal to one thing or another, you might think that this is possible:

# Incorrect...
if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
final meteor
#

Why am I able to reach my webserver im hosting myself if im connected to the same wifi but not if im connecting from outside my wifi?

cloud spruce
# final meteor Why am I able to reach my webserver im hosting myself if im connected to the sam...

From outside your wifi, you mean from the internet?
on your wifi you use private ip addresses, these can not be reached from the internet where only public ip addresses are used
your home router asks your ISP (Internet Service Provider) for a public ip address to use for a while and get one of those ip addresses
the home router is also a firewall and does something called source NAT (Network Address Translation) and masks the private ip addresses so that it looks to the rest of the internet like the traffic is coming from the router/firewall
to be able to get connection from outside to a host on the inside you will have to login to your home router as an administrator and setup something called port forwarding

final meteor
prisma cobalt
#

if your on windows, open CMD and type ipconfig and you'll see something like this (the ip might/will be different)

#

then type that ip into your browser and hopefully there will be a login page

silent yoke
#

does anyone know any free vm for m1 macs?

final meteor
prisma cobalt
#

Ghost ping 😶

prisma cobalt
#

That will take you to your routers admin page

final meteor
#

Yeah I managed to login to the configuration webpage but im not sure how to set it up securely and correctly

prisma cobalt
#

Do you see a port forwarding tab?

final meteor
#

Yeah

cloud spruce
final meteor
cloud spruce
# final meteor

strange setup, the router should know its own external/public ip address, so usually you don't have to put that in, here it looks like you will have too 😕

final meteor
#

But im just guessing

cloud spruce
final meteor
#

I mean I am configuring this to make my webserver visible to everyone else so that wouldn't necessarily be bad?

cloud spruce
final meteor
#

Yeah that wouldn't make much sense though since the gateway isnt really considerd external? I always thought of it as on the network

cloud spruce
#

the router must have an external and publicly routable ip address on the wan (outside) interface or this won't work

mystic haven
#

why isnt my server staying open?

#
# Echo server program
import socket

HOST = ''                 # Symbolic name meaning all available interfaces
PORT = 8820              # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)

conn, addr = s.accept()
print('Connected by', addr)
while 1:
  data = conn.recv(1024)
  if not data: break
  conn.sendall(data)


conn.close()

lost dagger
sharp osprey
#

does ip(public) tracking track all search results or searches on a browser?

mystic haven
cloud spruce
cloud spruce
lost dagger
prisma cobalt
sharp osprey
#

yeah thanks guys🥰

cloud spruce
# sharp osprey yeah thanks guys🥰

your ISP and some government branches of the country where you are connected to the internet might be tracking connections, dns lookups and other data as well

sharp osprey
#

nah not that serious it's just a casual site :p

cloud spruce
sharp osprey
#

yeah they prolly even do that but nothing i can really do abt it can i other than switching browser ig...

cloud spruce
# sharp osprey nah not that serious it's just a casual site :p

for google and other companies this is big business and the foundation of income for internet advertisement
some browser extensions and other software on your computer might do the same as the browser can and collect this data and send it to the cloud as well

sharp osprey
#

i see ||so no privacy||

cloud spruce
sharp osprey
#

mhm

prisma cobalt
opaque gulch
#

Anyone knows how I could make a program (on win10) go through a specific proxy
only that specific program

cloud spruce
opaque gulch
cloud spruce
scenic jetty
#

When I use this code

#

It doesn't write the CSV file....instead it writes this file:

errant bayBOT
#

Hey @scenic jetty!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

scenic jetty
#

that is the file that gets written.

#

Any ideas?

cloud spruce
# scenic jetty Any ideas?

looks like it's a page that contains javascript that your browser probably runs before the download process starts, but your script instead downloads the page with the javascript on it that would initiate that download

scenic jetty
#

think i should use selenium instead?

cloud spruce
opaque gulch
#

Yes

cloud spruce
# scenic jetty think i should use selenium instead?

either that or if you can work out what the real url is for the files you want that the javascript on that page fetches
you might start by bringing up the developer tools in your browser and check the network tab for which network resources it reaches out to

cloud spruce
scenic jetty
cloud spruce
scenic jetty
#

it might have

#

when i was researching i just found this way to directly download into a df

dense granite
#

Oi pessoal!! Eu acabei de partilhar um tutorial no Youtube sobre como instalar o banco de dados MongoDB. Então peço ajuda da comunidade pra partilhar e ajudar outras pessoas que precisam saber disso. E desde já eu agradeço acessar lá meu canal curtir e subscrever o canal da colega aqui tentando ajudar outros que estão iniciando na área de dados. Beijosss
https://youtu.be/da5f7619TNA

MongoDB - Tutorial Instalação


O MongoDB é um banco de dados orientado a documentos que possui código aberto (open source) e foi projetado para armazenar uma grande escala de dados (Big Data), além de permitir que se trabalhe de forma eficiente com grandes volumes.

Como Instalar o MongoDB Community Server no MacOS (Apple M1 - Monterey)

...

▶ Play video
errant bayBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

cloud spruce
dense granite
#

👍

kindred goblet
#

How do i get the folder name from the remote machines using PARAMIKO

cloud spruce
kindred goblet
#

I could get the size of folder

#

Not the name of the folder @cloud spruce

cloud spruce
kindred goblet
#
def b():
    for i in iter(_stdout1.readline,""):
      tot_size = sum(list(map(int, re.findall('\d+', i))))
      print(f"DATE {date} : {username} File size is {tot_size}  kb")

 remote=[f"/home/server2/Desktop/backupdestination/{year}/{month}/{date}/",f"/home/server3/Desktop/backupdestination/{year}/{month}/{date}/"]
 code1 = f'local = "{remotes!r}"; import os,json,sys; json.dump([os.path.getsize(os.path.join(path, filename)) for path, dirs, files in os.walk(local)for filename in dirs],sys.stdout)'
_stdin1,_stdout1,_stderr1 = client.exec_command(f"python3 -c '{code1}'")
kindred goblet
#

@cloud spruce

mystic haven
#

if I have a server and a client, how would I run both of them at the same time? pycharm limits to 1

#

the only thing that worked so far is running through both vsc and pycharm

#

one for clinet and one for server

cloud spruce
cloud spruce
mystic haven
#

whenever I run it in CMD its just stopping instantly

#

and opens pycharm

kindred goblet
kindred goblet
#

ANy one?

steady horizon
steady horizon
steady horizon
#

The quickest way is to use PyCharm's intelligence to run scripts that have an

if __name__ == "__main__":
    main()  # main should be a function running the main logic of the program and is generally good practice
#

PyCharm should show a green play button to the left of the keyword if

#

Or next to that line somewhere close

#

So you can write this line for both scripts and define each their own main function and click the button shown by PyCharm

mystic haven
#

but the server needs to be open first

steady horizon
#

Then click its play button first

#

Are they separate files?

mystic haven
#

yes

steady horizon
#

Good

mystic haven
#

ok

#

but I didn't really understand...
like I put both of them in the same main function in different files?

steady horizon
#

If you want to run the Python files just by clicking them in a file explorer window, there must be a setting for that in PyCharm

mystic haven
#

wouldnt they run at the same time?

mystic haven
#

it just opens pycharm

#
import socket
server_socket = socket.socket()
server_socket.bind(("0.0.0.0", 8820))
server_socket.listen()
print("Server is up and running")
(client_socket, client_address) = server_socket.accept()
print("Client connected")
data = client_socket.recv(1024).decode()
print("Client sent: " + data)
reply = "Hello " + data
client_socket.send(reply.encode())
client_socket.close()
server_socket.close()```
#

thats the socket

import socket
my_socket = socket.socket()
my_socket.connect(("127.0.0.1", 8820))
my_socket.send("yes".encode())
data = my_socket.recv(1024).decode()
print("The server sent " + data)
if __name__=="__main__":
  my_socket.close()
steady horizon
#
# server.py
...  # imports


def main():
    ...  # main logic


if __name__ == "__main__":
    main()
# client.py
...  # imports


def main():
    ...  # main logic


if __name__ == "__main__":
    main()
steady horizon
mystic haven
#

bruh it worked

#

thanks

#

yet Ik its very weird

steady horizon
#

Try binding the server on (socket.gethostbyname(socket.gethostname()), 8820)

mystic haven
#

like this in the server?

steady horizon
#

Or use the machine's private IPv4 address

steady horizon
#

Make these constants somewhere at the top of the file if you care, so that the program becomes more readable

mystic haven
#

yeah yeah

#

still doesnt work

#

like whenever I run it it does this

steady horizon
#

Do you see the green buttons shown in PyCharm though?

#

First click the one in the server script, then the one in the client script after the server is ready

mystic haven
#

yeah

steady horizon
#

Well what happens when you click the green button?

mystic haven
#

also (socket.gethostbyname(socket.gethostname()), 8820) isnt working

#

the preivous one does

steady horizon
#

Okay

steady horizon
mystic haven
steady horizon
#

Oh okay cool 👍

mystic haven
#

yet I still wonder why isnt the CMD working with it

steady horizon
#

Because of PyCharm's file association

#

It has set up a file association telling your computer to open Python files in its editor

mystic haven
#

do u know how can I cancel it?

mystic haven
#

thnaks

steady horizon
#

👍

bright orchid
#

Hey, when i send something (a list of the dir from a computer) and encode it with utf-8, i always get this error UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 864: character maps to <undefined> and i don't know how to fix it, any ideas?

mystic haven
#

@steady horizonoh bruh check our matual friends

steady horizon
#

Bruh

cloud spruce
# kindred goblet How can i use ```du -sk``` please help me <@936769916072259654>

i should have had my nickname changed to "Obi-Wan Kenobi" before that last mention 🤪

it's hard to work with the code when only partial code is provided so that we don't know what the different variables contain
for example: what does the variable username used in b() come from and contain? (so i have changed it in my code)
i also had to reverse engineer your intentions with the code in the code1 variable, especially as the expression f'local = "{remotes!r}"' won't do what you want it to even if was written as f'local = "{remote}"' (the variable name i think you intended) as such a value will not be accepted by os.walk(local)
but try something like:

def b():
    for i in iter(_stdout1.readline,""):
        tot_size, path = i.strip().split("\t")
        print(f"DATE {date} : {path} total size is {tot_size} kb")

remote = [f"/home/server2/Desktop/backupdestination/{year}/{month}/{date}/", f"/home/server3/Desktop/backupdestination/{year}/{month}/{date}/"]
dirs = ' '.join(f'"{path}"' for path in remote)
_stdin1, _stdout1, _stderr1 = client.exec_command(f"du -sk {dirs}")
kindred goblet
#

Username is server2 and server3 , I have 2 remote machines so I have named it server2 and server3

#
    tot_size, path = i.strip().split("\t")
ValueError: not enough values to unpack (expected 2, got 1)
#

b() is a function which helps to get the size of the folder/file from remote @cloud spruce

cloud spruce
# steady horizon Try binding the server on `(socket.gethostbyname(socket.gethostname()), 8820)`

@mystic haven this is a pattern that you should stay away from as it will only listen on one of the addresses/interfaces and it's very possible that it will pick up another [wrong] address/interface then the one you intended, as such it's very unreliable
unfortunately it's a common pattern in examples on the internet and even in documentation
it's much better to use:
'0.0.0.0' (for ipv4) or '::' (for ipv6) or '' (the empty string, works for any of the two) if you want it to listen to all addresses of that protocol version on the computer
or '127.0.0.1' (for ipv4) or '::1' (for ipv6) if you only want it to be accessible on the local computer

cloud spruce
cloud spruce
mystic haven
#

also why does this work only 1 time?
server

import socket
import datetime
from random import randint


def main():
    server_socket = socket.socket()
    server_socket.bind(("0.0.0.0", 8820))
    server_socket.listen()
    print("Server is up and running")

    (client_socket, client_address) = server_socket.accept()
    print("Client connected")
    while 1:
        data = client_socket.recv(1024).decode()

        if data == "TIME":
            client_socket.send(str(datetime.time()).encode())
        elif data == "WHORU":
            client_socket.send("BRUH".encode())
        elif data == "RAND":
            client_socket.send(str(randint(1, 10)).encode())
        elif data == "EXIT":
            client_socket.close()
            server_socket.close()


if __name__ == "__main__":
    main()

client ```py
import socket
import datetime

def main():
while True:
inp = input("Command to type: ")
my_socket = socket.socket()
my_socket.connect(("127.0.0.1", 8820))
my_socket.send(inp.encode())
data = my_socket.recv(1024).decode()
print("The server sent " + data)
my_socket.close()

if name=="main":
main()

cloud spruce
main spruce
#

Can I serve both html and websockets on the same port? I have now class Server(http.server.SimpleHTTPRequestHandler): on 8001 and websockets.serve(server.ws_handler, 'localhost', port) on 8008 ... makes my web app hardcoding the ports.

I want ie /ws become a websocket.

cloud spruce
main spruce
cloud spruce
main spruce
cloud spruce
umbral spindle
#

I wonder if some of u guys have easy tutorial for twisted

#

I almost get mad while learning it

#

🥲

cloud spruce
umbral spindle
#

Do you mean the official docs

cloud spruce
umbral spindle
#

that may make sense but I have am urgent 'task' that will be checked by my teacher tomorrow😰

#

I may need a quick tutorial

cloud spruce
umbral spindle
#

holy correct

cloud spruce
cloud spruce
errant bayBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

umbral spindle
#

yeah that's alright, it's just complaining or that kind of stuff

umbral spindle
#

no necessarily need for GUI

cloud spruce
umbral spindle
#

I hope so

#

I have prepared for a delay

#

If u know some related github projects with readable code or detailed md please let me refer to it

cloud spruce
umbral spindle
#

that's fine

split burrow
#

Hello

#

I’m greatly interested in coding trading bots. Indeed, I have built some trading algorithms and I aspire to build an investment fund with them. I came to this discord to expand my network and maybe find a business partner! So, if you are interested in coding trading bots, do not hesitate to contact me.

cloud spruce
normal gazelle
#

Is it okay to use JSON as a TCP application protocol? My current idea is to use a dictionary to store things such as username, command, and message then convert it to a string. I plan on replacing all curly brackets in the text before I insert it so on the server side I can check for the ending bracket '}'. Then once I find it I will convert everything bac using a reversed translation table.

#

the MTU size is the thing im worried about, with the stream being split up

normal gazelle
#

nvm

#

I solved it

cloud spruce
# normal gazelle the MTU size is the thing im worried about, with the stream being split up

don't worry about the MTU, tcp will take care of that for your
but i would still recommend calling recv() with a buffer size of 2048 bytes or 4096 bytes on the most common networks and for internet traffic instead of 1024 bytes, so that your code don't need to call recv() multiple times for the content of the same packet in the stream, way to many examples on the internet put 1024 bytes there which just leads to unnecessary number of system calls

normal gazelle
#

well no matter what I have to check for MTU size (custom clients, random data etc) but I managed to fix it

#

since length checks are on server side i cant limit what comes through

cloud spruce
normal gazelle
#
data = await reader.readuntil(b'}')
#

yeah thats what I ended up doing

#

then I just convert on the server using a reverse table

cloud spruce
normal gazelle
#

Well I would have to since a user could input that

#

and I could add a fixed header length client side but then it could cause a ton of errors and I would have to add even more exception catches with trying read bad data lengths etc

normal gazelle
#

also how would you store clients? I currently have the username as a key in a dict and writer as the value but I feel like this is bad

sly shell
#

how do I install pynput in pycharm

cloud spruce
normal gazelle
#

okay, but should I have the username as the key or the writer as the key?

thorn stratus
normal gazelle
#

I'm using ascii characters 2 and 3

#

to replace the brackets

thorn stratus
#

why not just use ascii character 3 to indicate the end of the message

cloud spruce
normal gazelle
thorn stratus
thorn stratus
#

unless you want to be sending things to specific usernames usually, then it makes sense to put it in a dict with the username as the key

normal gazelle
#

yeah im sending to specific names

#

its odd picking a data type though, because half the time I access only the writer and the other time I access the writer through the username. Like {username:writer} when a person wants to send someone a specific message by typing in their username

#

ill just post my code in a second

normal gazelle
#

I removed the translation just so its easier to read but thats some of the code

#

I re wrote a lot of it in the past few hours an removed a majority to start fresh

#

also, should I include a 'type' into my data? For example with direct messaging and doing other things such as recconecting, it would be a lot easier I think on the client side to display that if I had something such as a type

#

like...this would be a normal message that gets broadcasted from the client : {'message':message} then from the server to everyone depending on command prefixes etc : {'username':username, 'message':message, 'type':'direct'}

glass zephyr
#

do you know any good proxy list or api ?

glacial oriole
#

hi

viscid topaz
#

Hello, I have problem with connection to smtp servers with port 25. Few days ago I experiment with validation email with connection to smtp server, but now I can not connect to any server. Is possible that the ISP block my port 25 with cause of spamming or should by problem anywhere?

#

Thanks

cloud spruce
viscid topaz
#

but I can connect to gmail using port 587 so i don't know why he ban only port 25

cloud spruce
# viscid topaz But now I can not connect to ISPs smtp server

that's unusual, they often have a few SMTP servers that they host that only their customers can connect to for for outgoing e-mail
and it's pretty common that they only filter port 25 to try to block people from sending spam to SMTP servers out on the internet, that is also why google run their SMTP server for their users on another port to work around that

prisma cobalt
#

@normal gazelle i believe discord websockets have this "problem". they send event data in json form which is similar to what you want to do. if you implement websockets (or easily install a library) then you dont have to worry about any of this. unlike TCP, every send call corresponds with a single recv call client side as websockets implement a short header containing the full message length. for efficiency, you dont need to do the HTTP handshake to begin with but thats up to you

prisma cobalt
normal gazelle
#

I would use websockets but I'd rather solve it doing normal TCP streams rather than skipping over the issue, also I'm pretty sure that's what almost all tcp streams do so I'm not sure how it's flawed, they have to have some indicators that the message line is ending or starting, in my case I'm using asyncio so the input is waiting always

cloud spruce
ember ledge
#

I am looking for a peer to peer network mentor.

kindred goblet
#

Hey

#

I have a code which connect to a network

#
if previous > state:
        print("is critical")
        print(f'Because There are no {result3} in {yesterday}  comapred to {day_before_date} so the state is critical ')
        #riemann.send({'host': 'server', 'service': 'chirag','state':'critical'})
        try:
          riemann.send({'host': 'server', 'service': 'chirag','state':'critical'})
        except:
          print("Riemann is not connected and to connect to riemann run the commands ,`bin/riemann etc/riemann.config`,'riemann-dash' ")

      if len(previous_clients)==0 and len(current_clients)==0:
        print("")
        print(f"There are no clients on DATE : {day_before_date} and DATE : {yesterday}")
        print("STATE : is Okay")
        try:
          riemann.send({'host': 'server', 'service': 'chirag','state':'ok'})
        except:
          print("Riemann is not connected and to connect to riemann run the commands ,`bin/riemann etc/riemann.config`,'riemann-dash'  ")
      if previous_clients == current_clients:
        print("")
        print(f"DATE :{yesterday} and DATE :{day_before_date} have equal number of clients , so the State will be OK")
        print("STATE : is Okay")
        try:
          riemann.send({'host': 'server', 'service': 'chirag','state':'ok'})
        except:
          print("Riemann is not connected and to connect to riemann run the commands ,`bin/riemann etc/riemann.config`,'riemann-dash' ")
    previous= state
#
Exception connecting to TCP socket: [Errno 111] Connection refused
Traceback (most recent call last):
  File "/home/server/.local/lib/python3.8/site-packages/bernhard/__init__.py", line 48, in __init__
    self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
Riemann is not connected and to connect to riemann run the commands ,`bin/riemann etc/riemann.config`,'riemann-dash' 
#

After running the code and trying to resolve issue i get could get till this output
Is there any way where i can get only the last line printed and ignore the remaining part?

sweet karma
#

Hey,

i am first time using api in python with auth and i have issues how to do it. Can someone help me to understand? I sitting for hours watching tutorials ;-;
https://dev.streamelements.com/docs/kappa/ZG9jOjE4MDk3Njc-o-auth2
https://streamelements.com

misty frost
#

Make sure if you dont know a term or idea, you review before proceeeding

sweet karma
#

@misty frost thanks

#

I already got it fixed

opaque gulch
#

Could someone please explain to me what is "reverse tunneling" in layman's language ?

cloud spruce
prisma cobalt
#

how can the select module be used with non-blocking sockets, whats the point of putting the sockets into non blocking mode if you use select?

cloud spruce
# prisma cobalt how can the select module be used **with** non-blocking sockets, whats the point...

even if select(socket_list) returns immediately when using non-blocking sockets it will give you three lists back which i think does hold quite much value
the first with all sockets that actually does have any data waiting to be read, the second with all sockets that are ready to be written to and a third with all sockets that has any exceptional state (like lost the peer) and then you can process one or several of those lists instead of iterating through all the sockets to check each one of them for such conditions

cloud spruce
# prisma cobalt how can the select module be used **with** non-blocking sockets, whats the point...

select() is efficient under linux and many other unix dialects as it's often implemented with backing from other mechanisms in the kernel like epoll

if you're targeting windows with your software you should probably use other methods instead of select(), such as iocp (I/O Completion Ports) with win32file (which interfaces with windows APIs for overlapped I/O https://en.wikipedia.org/wiki/Overlapped_I/O among other things) from pywin32

steady horizon
#

Or... You can use asyncio

fading trellis
#

ptables v1.8.4 (legacy): invalid port/service `http,https' specified
What does this mean?
The command I used: $ sudo iptables -A INPUT -p tcp --dport http,https -j DROP

steady horizon
#

Try using the ports for those protocols (HTTP: 80, HTTPS: 443 I think)

cloud spruce
cloud spruce
prisma cobalt
steady horizon
#

Using select or poll you still handle sockets synchronously in the application side of things

cloud spruce
errant bayBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

cloud spruce
# prisma cobalt im making my own concurrent backend :)

as @steady horizon noted, it won't be concurrent
unless you use async/await and it's an I/O bound load or you go multi-process and IPC which would allow you to use multiple cores on a system and be able to handle cpu bound loads as well
even with threads it won't really be concurrent in python due to the GIL, unless you're calling C/C++ libraries that release the GIL and does much of the work outside of python before reacquiring the GIL and without spending to much of it's time exchanging data with the python parts of the library code as that also requires it to hold the GIL

prisma cobalt
#

ive already got a concurrent sockets down, i was just wanting to implement the async/await keywords into the project

proud swift
cloud spruce
#

even if this is kind of network related i think it even more #unix related where it's mainly linux, let's continue in there

steady horizon
#

I made a simple scheduler with a sleeping function of my own, completely without a library

ember ledge
#

can anyone recommend a library for making your own proxy/load balancer? Existing solutions always have some little issues (hot load config, performance, either socks or http, etc.)

prisma cobalt
cloud spruce
steady horizon
prisma cobalt
steady horizon
#

You can have non blocking sockets

native star
#

Someone help@me with some questions

prisma cobalt
#

generators doesnt require non blocking sockets btw

cloud spruce
regal roost
#

can i get help?

#

i am trying to connect to a server using python

#

i need to send 3 messages

#

1 is a post request with the login info and the other 2 are get requests

#

i managed to send the post request

#

but no matter what i try to do, the get requests arent working

cloud spruce
regal roost
#

thanks!

#

that was it

rancid cosmos
#

if my host provider doesnt have ipv6

#

but im using cloudflare, and it auto proxies ipv4 into ipv6

#

can i just delete my ipv6 AAAA record

#

in cloudflare?

#

I imported one cloudflare account into another, and I'm getting some Error 1000

#

because i think it imported some of the proxied ips from the previous cloudflare account

#

I replaced most of the ipv4 with my host ip and it's functioning correctly, but every now and then i get the error 1000 and i suspect it's because my AAAA records are not accurate

cloud spruce
rancid cosmos
#

i am confused because my load balancer, through my host provider, does not have ipv6

#

so what am i supposed to put into the new cloudflare account

#

on a side note how would i even test this, because error 1000 is not an error that pops up every time

cloud spruce
rancid cosmos
#

and point them to cloudflare ipv6s

#

?

cloud spruce
rancid cosmos
#

when i imported the old CF account into my new one, it brought up some duplicate entries, and since my host does not have ipv6, it copied over the proxied ipv6s from the old CF account

#

for the ipv4s it was easy to debug, i just looked at my hosts load balancer

#

but for the ipv6s, i am not sure how to fix this, because I can't tell what ipv6 I should have

#

it imported 2 ipv6s

#

and i cant tell which one i should use

#

or if i should somehow find a new CF ipv6 or something

cloud spruce
#

sounds like quite a mess
is the plan to use cloudflare services in front of your hosting providers load balancer or are do you only want to use cloudflare for DNS hosting?

rancid cosmos
#

id like to use CF for DNS hosting

#

or idk actually

#

my hosts lb is not meant for DNS stuff

#

thats for certain

#

if i delete the ipv6s

#

and toggle ipv6 off in the network tab

#

then turn it back on, shouldn't it provide a new ipv6

cloud spruce
# rancid cosmos id like to use CF for DNS hosting

if you want to only use them for DNS hosting and nothing more, then you should remove the AAAA records and just have the A or CNAME record point to your hosting providers load balancer
but if you want to use the cloudflare protective services you should have both A and AAAA records or a CNAME record that points to what ever cloudflare thinks it should point to to reach their cloud services

rancid cosmos
#

but what if my LB doesn't support IPv6, how would i point it

#

because AAAA records are supposed to be IPv6?

#

l see that CF enables IPV6 by default

cloud spruce
# rancid cosmos but what if my LB doesn't support IPv6, how would i point it

as i said, if you are not using cloudflare as a web reverse proxy in front of your hosting providers load balancer and only want to use cloudflare to host DNS you can remove everything that has to do with ipv6 including the AAAA records, then you would let the remaining A and/or CNAME records point directly at your hosting providers load balancer

cloud spruce
cloud spruce
# rancid cosmos l see that CF enables IPV6 by default

probably because their own services has IPv6 support and if you use their other services (not just DNS) in front of your site they can accept both IPv4 and IPv6 traffic to their services and they'll reverse proxy all the traffic to your server (or in your case, your hosting providers load balancer) even if it just supports IPv4 and not IPv6 (cloudflare would in the case of being a reverse proxy take care of the conversion between IPv6 from such clients to IPv4 to your server)

rancid cosmos
#

whats that

cloud spruce
# rancid cosmos but i do want CF protection

then that is another story, then your site will support both IPv4 and IPv6 through cloudflares infrastructure and services even if that traffic is then sent to your hosting providers load balancer only through IPv4

rancid cosmos
#

but how can i find what cloudflares ipv6 is? like what ip do i need to find

cloud spruce
# rancid cosmos i need to do this

yes, and cloudflare should either be in direct control of the DNS entries for that or you'll find instructions from then what to point your DNS towards to accomplish that

rancid cosmos
#

ok my last question

#

how can i test this out, and trouble shoot, because the 1000 error only occures randomly

cloud spruce
rancid cosmos
#

yeah ive looked at that link

#
If an A record within your Cloudflare DNS app points to a Cloudflare IP address, update the IP address to your origin web server IP address.

There is a reverse-proxy at your origin that sends the request back through the Cloudflare proxy. Instead of using a reverse-proxy, contact your hosting provider or site administrator to configure an HTTP redirect at your origin.```
#

so my error might not even be because of the AAAA records

cloud spruce
rancid cosmos
#

i went ahead and deleted the AAAA records

#

but again i have no way of knowing if this error will pop up again

#

until it does

cloud spruce
# rancid cosmos but again i have no way of knowing if this error will pop up again

let's fix this now
if you have opted to set your site to be proxied by cloudflare they will take care of the real A and AAAA records automatically
in the case where you have the proxing enabled you'll instead set only the A records (as your hosting provider does not support IPv6) to point to the load balancer at your hosting provider, you will not be able to use AAAA records in this case but cloudflare solve that for you anyways
this will not be the real A records that the rest of the world sees, this is only for cloudflare so that they know where to reverse proxy the traffic
this should take care of the "error 1000" problem, because for proxied records you can not point them towards cloudflare, that would be a circular flow which cloudflare detects and gives you "error 1000" for

rancid cosmos
#

so yes everything is proxied

#

so just set all A record IPs to host provider

#

and delete all AAAA records

cloud spruce
rancid cosmos
cloud spruce
rancid cosmos
#

not at the same location as my website

#

i outsourced the email stuff, like i have a paid outlook

#

but lets say it might take me a while to figure that out

#

would i still have the 1000 error?

#

since it's not routing traffic to my lb for emails and such

cloud spruce
elder cobalt
#

Hello wanted to know has anyone here used pydivert before? Since I'm not aware if Scapy can modify packets before entering the windows network stack?

earnest jacinth
#

Hi, i'm really a beginner so can someone please explain me how you would go about making a Json with messages in it readable for humans and then send it to someone on an app like telegram ?

cloud spruce
halcyon quartz
#

yo dudes

#

i want to make a simple app

#

that receives and sends messages to my friend who is on a different network

#

the problem is as u know already u cant bind to a public ip

#

tried port forwarding

#

did a bind on the port and local ip

#

tried to connect to the public ip from my friends network nothing happened

#

basically

#

s.bind(my local ip, the port i set in the port forwarding rules )

#

client side

#

s.connect(my public ip, same port )

wraith ice
#

Your destination will be friend_public_ip:port and they’ll need to do a static Port translation which might be PAT on the router.

wraith ice
#
 ┌──────────────┐
 │   Computer   │
 │     with     │
 │   Python     │
 └──────────────┘

    dst ip 4.4.4.4
    dst port: (above 1024)
          │
          │
          │
          ▼
 ┌──────────────┐
 │              │
 │  home router │
 │  7.7.7.7     │
 └──────────────┘

  dst ip 4.4.4.4
  dst port: (above 1024)
        │
        │
        │
        ▼
 ┌──────────────┐
 │              │
 │  home router │
 │  4.4.4.4     │
 └──────────────┘

         '''port address translation
        │   converts the 4.4.4.4 to the
        │   friend computer IP'''
        │   dst ip 192.168.1.1
        │   dst port: (above 1024)
        ▼
 ┌──────────────┐
 │  Friend      │
 │  Computer    │
 │ 192.168.1.1  │
 └──────────────┘```
#

@halcyon quartz keep in mind this translation happens in both directions but only the source IP is changed by the local router and the far end router works out converting the destination IP.

wraith ice
#

sounds like a fun project, good luck 👍

halcyon quartz
#

thanks man and this drawing really helps

#

thanks for putting in that extra effort

wraith ice
#

you're welcome

#

i think the tricky thing will be editing firewall rules and NAT/PAT on each router. The python code will be the fun bit

halcyon quartz
#

yeah but at least now i have a direction/ a thing to do i was just lost looking for solutions

#

ill learn how to do that rn

cloud spruce
# halcyon quartz yeah but at least now i have a direction/ a thing to do i was just lost looking...

if you both can reach things out on the internet (which i assume), then SNAT (Source Network Address Translation) is already configured in both of your routers, so you won't have to worry about that part
you should only have to deal with the port forwarding configuration, and maybe firewall rules if that isn't automatic in your router when setting up port forwarding (which it usually is
they you may also have a problem with your computer running a host firewall that you need to open, so that things can connect to the listening port your program sets up, this may very well be your problem right now if you've already done the port forwarding

ember ledge
#

Can someone show me urllib3 perfect api call funtion?

#

Something like ```py
def HTTP(method,url,body,header):

#

Handling all exceptions

copper swan
#

in sockets you know how once we establish a connection from the client, you use conn to handle that client. And that client has a different port. As in something like this:

[+] Connection Established 192.168.0.25:55365```
#

how can you access the second port from the client side; second port meaning the 55365

prisma cobalt
#

its the router that performs this port translation for you so there might be a setting in your routes home/admin page @copper swan dont get too excited though since to my knowledge, many routers dont show this setting or allow modification to it

#

otherwise, you would have to get the server to send you (the client) the port that your using

copper swan
#

ohh cool thanks

cloud spruce
# copper swan ohh cool thanks

@prisma cobalt is talking about your typically home router which is also a firewall capable of SPI (Stateful Packet Inspection) and will also apply SNAT (Source Network Address Translation) to traffic going from your internal network (LAN) to the internet (WAN), in doing so it will change the ip address from a private ip (used within your LAN) to the public ip address that your router/firewall was given by your ISP (Internet Service Provider) and the source port for the packet will typically (but not always) also be changed during this process.
This means that the server that you connect to out on the internet through such a router/firewall will see another source ip address and source port then what your client thinks it has.

Within the same network this process does typically not take place, so if the client and server shares the same network they will have the same view of the world then it comes to the source ip address and source port.

If you have access to the socket object for the connection on the client as the variable conn, the quite nonintuitive conn.getsockname() will give you both the local ip address and local port in use for that connection.
This last part is what I think your original question was really about.

prisma cobalt
#

this very well detailed answer

cloud spruce
copper swan
#

I got another question... if your socket program is already connected to a user suppose like 192.168.0.25:4545 and in the middle of communication if i run a connect((host,port)) to that ip and port it still accepts the connection

#

is it possible to make something that would accept new connections if a prior connection to that server doesn't already exist

#

i tried using the router assigned port cuz its unique for each connection, but its getting overly complicated if i do it that way

#
if __name__ == "__main__":
    HOST, PORT = "192.168.0.25", 4545
    counter_check = 1
    while True:
        try:
            time.sleep(8)
            s = Client(HOST, PORT)
            s.enable_attempt_reconnect()

            if counter_check == 1:
                proc = multiprocessing.Process(target=s.start_code)
                proc.start() #starting the thread for reverse shell
                counter_check += 1

            elif proc.is_alive():
                proc.terminate() #forcefully close the previous thread
                proc = multiprocessing.Process(target=s.start_code)
                proc.start() #start a new thread


        except Exception:
            continue
#

enable_attempt_reconnect()

#
def enable_attempt_reconnect(self):
        while True:
            time.sleep(3)
            try:
                self.soc.connect((self.host, self.port))
                break        
            
            except Exception:
                continue
copper swan
#

anyone?

copper swan
#

yoo anyoneee?

cloud spruce
cloud spruce
earnest blaze
#

Not a networking problem and the image is upside down...

cloud spruce
#

!rule 8 looks like it would apply here
!rule 7 as it's very much off-topic as this doesn't relate to networking at all
a z- grade for the [total lack of] effort with a upside-down picture of the problem
the proper way would be to post text describing what you need help with and some code of what you have tried so far
we are not code bots that produces code for you upon request

errant bayBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

elder cobalt
#

if anyone could help me out it'd be helpful

#

been trying to figure out but just can't seem to get it to work

cloud spruce
elder cobalt
#

anything else I can provide?

cloud spruce
cloud spruce
#

!e

import struct

string_50_digits_of_pi = "3.1415926535897932384626433832795028841971693993751"
bytes_close_to_pi = b"\xd0\x0fI@"
bytes_closer_to_pi = b"\xdb\x0fI@"
float_closest_to_pi = float(string_50_digits_of_pi)

# `struct.unpack()` gives you a tuple
# but you just want the float in the first element of that tuple
# `[0]` will fix that
print(f"    close: {bytes_close_to_pi} ---> {struct.unpack('<f', bytes_close_to_pi)[0]}")
print(f"   closer: {bytes_closer_to_pi} ---> {struct.unpack('<f', bytes_closer_to_pi)[0]}")
print(f"  closest: {struct.pack('<f', float_closest_to_pi)} <--- {float_closest_to_pi}")
print(f"   50 digits of pi as string: {string_50_digits_of_pi}")
print()

data = bytearray(b"ABCDEFGHIJKLMNOPQRSTUVWXYZ")  # dummy data
data[18:22] = bytes_close_to_pi
print(f" data before: {data}")
print(f"    {struct.unpack('<f', data[18:22])[0]}")
data[18:22] = struct.pack("<f", float(struct.unpack("<f", data[18:22])[0] + struct.unpack("<f", b"\xd0\x0fI@")[0]))

print(f"  data after: {data}")
print(f"    {struct.unpack('<f', data[18:22])[0]}")
print(f"    {struct.unpack('<f', bytes_close_to_pi)[0] * 2} = {struct.unpack('<f', bytes_close_to_pi)[0]} * 2 = {struct.unpack('<f', bytes_close_to_pi)[0]} + {struct.unpack('<f', bytes_close_to_pi)[0]}")
errant bayBOT
#

@cloud spruce :white_check_mark: Your eval job has completed with return code 0.

001 |     close: b'\xd0\x0fI@' ---> 3.141590118408203
002 |    closer: b'\xdb\x0fI@' ---> 3.1415927410125732
003 |   closest: b'\xdb\x0fI@' <--- 3.141592653589793
004 |    50 digits of pi as string: 3.1415926535897932384626433832795028841971693993751
005 | 
006 |  data before: bytearray(b'ABCDEFGHIJKLMNOPQR\xd0\x0fI@WXYZ')
007 |     3.141590118408203
008 |   data after: bytearray(b'ABCDEFGHIJKLMNOPQR\xd0\x0f\xc9@WXYZ')
009 |     6.283180236816406
010 |     6.283180236816406 = 3.141590118408203 * 2 = 3.141590118408203 + 3.141590118408203
cloud spruce
elder cobalt
#

doing basic operations like addition/subtraction/multiplication and division with the incoming 4-byte stream before being sent into Window's network stack

cloud spruce
#
data[18:22] = struct.pack("<f", struct.unpack("<f", data[18:22])[0] + struct.unpack("<f", b"\xd0\x0fI@")[0])
```for addition or whatever feels quite cumbersome but it works 🤷
someone with better python skills then me might be able to come up with something both simpler and more efficient
cloud spruce
elder cobalt
#

I've wanted to simulate my car facing backwards with the help of packet editing, right now I get an IEEE 754 floating point packets from data[18:22] when I face forward I get packets which are 1.000785 when rounding of it's 1 radian so if I were to make my car face backwards I'd most likely want it to multiply by -1 so that the car faces the opposite direction

#

that was like my whole thought process

cloud spruce
elder cobalt
cloud spruce
#

all this is really more like #python-discussion, but you are manipulating network packets with this code, so... 🤷

stray egret
#

do anyone here know all possible arguments for the data dictionary requests.post(url, json=data) when sending discord messages using webhooks? or just embeds properties

cloud spruce
rain wave
#

oh really?

elder cobalt
#

@cloud spruce Just came across this thought not sure why it's not working, I am trying to make the car spin around it's X axis. Here is how I altered

circle_radians = [0, 1.5708, 3.14159, 4.71239, 6.28319] # Goes from 0 degree all the way to 360 degrees



with pydivert.WinDivert("udp.SrcPort = 61572  and ip.DstAddr = 146.19.191.145 and udp.PayloadLength = 62") as w:
    for packet in w:
        data = bytearray(packet.payload)
        for i in circle_radians:
            data[18:22] = struct.pack("<f", i) # Testing
        #data[18:22] = struct.pack("<f", struct.unpack("<f", data[18:22])[0] + 3.14159) # Changes car orientation to reverse
        #data[26:30] = b"\xd0\x0fI@" # Custom Z rot. data
        packet.payload = bytes(data) # Writes custom data to the stream
        #data1 = bytearray(packet.payload)
        #data1[10:14] = struct.pack("<f", struct.unpack("<f", data[10:14])[0] + 1) # Adds +1 height to the car in meters
        #packet.payload = bytes(data1) # Writes custom data to the stream
        w.send(packet)


        X_rot = packet.payload[18:22] # Checking X_rot (front/back)
        Y_rot = packet.payload[22:26] # Checking Y_rot (up/down)
        Z_rot = packet.payload[26:30] # Checking Z_rot (left/right)
        print(struct.unpack('<f', X_rot), "|", struct.unpack('<f', Y_rot), "|", struct.unpack('<f', Z_rot)) # Printing live XYZ rotation.```
#

I created a for loop for circle_radians so that it sort of simulates going in a circle

#

but doing that so I can't find my X rotation to change the way I intended it to do so

#

sorry for the changes

#

this is how my X coordinate looks

#

after that change

cloud spruce
# elder cobalt <@936769916072259654> Just came across this thought not sure why it's not workin...

i don't understand why you would like to loop through circle_radians like that , it should be the same thing as doing:

circle_radians = [0, 1.5708, 3.14159, 4.71239, 6.28319]
circle_radian = sum(circle_radians)

with pydivert.WinDivert("udp.SrcPort = 61572  and ip.DstAddr = 146.19.191.145 and udp.PayloadLength = 62") as w:
    for packet in w:
        data = bytearray(packet.payload)
        data[18:22] = struct.pack("<f", circle_radian)

        ....
```and now you're always setting it to the same value which is the sum of `circle_radians`, that is probably not what you want
elder cobalt
#

oh yeah there's already a for loop

cloud spruce
cloud spruce
elder cobalt
#

with a for loop

#

so it'd go from 0 degrees and then finish a full circle and again start from 0 and kept going

cloud spruce
#

your just overwriting the same value over and over, before the change to the code it was the sum of those, now it's just the last value over and over

elder cobalt
cloud spruce
#

what you are doing after the changes is this instead: data[18:22] = struct.pack("<f", circle_radians[-1])

elder cobalt
cloud spruce
elder cobalt
elder cobalt
cloud spruce
cloud spruce
elder cobalt
#

also when I use

data[18:22] = struct.pack("<f", circle_radians)```
without the [-1] I understand that it's going to pick the first value and that's zero but for some reason it's saying
#

struct.error: required argument is not a float

cloud spruce
elder cobalt
#

ohhh

#

yeah wtf

#

if I use [0] it starts from the 0th position of the list

#

hmm my X values still stay the same even though its in a for loop

#

a well using print(circle_radians[-1]) does not seem to work because then it's only printing 6.28319, shouldn't I create another loop for i in circle_radians[-1] that way it iterates through all the value and assign them at the same time?

cloud spruce
cloud spruce
#

this code will go through the list one entry at a time for each packet and then start over with the first entry in the list and so on

elder cobalt
#

len(circle_radians) would return 5 right?

cloud spruce
elder cobalt
#

oh yeah makes alot more sense now

#

5%5 will return 0, so it'll iterate to the 0th position of the list

#

and so on it continues

#

nice it's working! @cloud spruce but the output seem so jagged, any idea how I can make it readable?

#

thanks alot so far as well

cloud spruce
cloud spruce
# elder cobalt thanks alot so far as well

no problem
you where talking about going backwards by taking the current value * -1 on the float
if i'm not mistaking that will just change the sign of the value from positive to negative or negative to positive
that's actually a special case as there is only one bit that signifies if the value is positive or negative and can be done much more efficient with a bitwise xor on that bit to flip it

cloud spruce
# elder cobalt thanks alot so far as well

it would look like this:

with pydivert.WinDivert("udp.SrcPort = 61572  and ip.DstAddr = 146.19.191.145 and udp.PayloadLength = 62") as w:
    for packet in w:
        data = bytearray(packet.payload)
        # flip the most significant bit of the last byte of the four bytes that make up the float to flip sign on the little-endian encoded float
        data[21] ^= 128
#

easy and efficient

elder cobalt
elder cobalt
cloud spruce
elder cobalt
cloud spruce
# elder cobalt Also should I just place data[21] ^= 128 after data = bytearray... and what does...

^ is the bitwise xor operator (that in python unfortunately can only operate on integers for some reason)
doing a xor on a bit flips it from 0 to 1 or if it's a 1 it will become a 0
128 is "1000 0000" in binary, so will flip that bit first (most significant) bit of that byte
it just happens to be the bit that sets the sign (+ or -) for the float
and ^= does this on the value of the variable and assigns it back to the same variable

cloud spruce
# elder cobalt Will try this out tomorrow thanks again

a more general solution would be:

extra_rotation = 1.5708

with pydivert.WinDivert("udp.SrcPort = 61572  and ip.DstAddr = 146.19.191.145 and udp.PayloadLength = 62") as w:
    for packet in w:
        data = bytearray(packet.payload)
        data[18:22] = struct.pack("<f", struct.unpack("<f", data[18:22])[0] + extra_rotation)
fair hedge
#

ssh -f -i "[PEM file]" [EC2_user]@[EC2 endpoint] -L 3307:[RDS endpoint]:[RDS port] -N

#

how can I write this is sshtunnel through python?

ember ledge
#

does anyone know how I can prevent from my network console (all the requests) from refreshing

#

like all these requests go away

elder cobalt
cloud spruce
cloud spruce
ember ledge
#

!rule

errant bayBOT
#

The rules and guidelines that apply to this community can be found on our rules page. We expect all members of the community to have read and understood these.

final meteor
#

Why does my phone not get an IP address on my wifis subnet when I connect it?

cloud spruce
wide nest
#

In the past I have automated a spine leaf architecture. This was easy if all the uplinks are the same speed. Port 1 = Leaf 1. But how would you handle assigning ports and IPs if some of the switches need to be broken out. For examples if you have a spine with 100g ports but some of the switches need to broken out to use 25gb ports.

stray egret
#

How do i use and create an API?

cloud spruce
stray egret
#

i mean like api when you send a request for getting and uploading small data

#

i want to have two computers that have one python program with the link, communicating with eachother

cloud spruce
# wide nest In the past I have automated a spine leaf architecture. This was easy if all the...

1x100 Gbps port (let's call it Eth23) usually splits out to 4x25 Gbps ports (like Eth23/1, Eth23/2, Eth23/3 and Eth23/4), you could assume all ports are broken out like that and for those in 100 Gbps mode you can use it like if it was the first sub-port and just skip over the numbers for the other "would-be" sub-ports for that port, then it's easy to count, for example for either the full 100 Gbps port or the first sub-port of that port (really makes no difference) you can number it like (port_num-1)*4+1, for the example above it would be (23-1)*4+1=89

stray egret
#

ok..

#

i "understand", mabye im just asking too advanced questions

prisma cobalt
prisma cobalt
# stray egret How do i use and create an API?

checklist of understanding:

1) sockets
2) HTTP
3) API

you need a secure knowledge of the format of HTTP requests/responses before you roll your own api
if your looking to simply use a library then i'd recommend FastAPI

stray egret
#

FastAPI, is it some website that hosts apis?

cloud spruce
prisma cobalt
prisma cobalt
stray egret
#

i think im not skilled enough to even think about this i think

cloud spruce
stray egret
#

ok

cloud spruce
stray egret
#

some sort of chatting program

wide nest
#

@cloud spruce How would I automatically cluster the 25 gig ports?

cloud spruce
stray egret
#

app communicating with api

cloud spruce
# stray egret app communicating with api

okay, as you want to go with an api, simple sockets are out, but it will at the same time give you the flexibility to be able to build a web based client front-end later as well if you would like to down the road 👍

cloud spruce
wide nest
#

@cloud spruce Right, like if I have 5-100g switches and then 13 -25g switches.

#

Arista

cloud spruce
wide nest
#

@cloud spruce But in the example if I had an odd number of ports what happens when I add more switches? Will it just leave some ports blank or try to stick a 100g into a subinterface?

cloud spruce
cloud spruce
# wide nest <@936769916072259654> But in the example if I had an odd number of ports what ha...

i think you will find it hard to maintain a one to one mapping between port number and leaf number in the long run anyways
for example we found it better to number the leafs in pairs that are running mlag between them to be named like leaf1a and leaf1b instead of just leaf1 and leaf2, and already there one can't maintain the port number to leaf name mapping anymore
i understand if this isn't an appealing idea to you as i also would have liked to keep a 1-to-1 mapping and probably have a little ocd when it comes to keeping things nice and tidy, keeping numbers in order and such to be able to keep track of things without having too look things up all the time, but as I have found it unfeasible to maintain that order everywhere and and at any cost as complexity grows
you might want to have a system such as netbox (open source) or comparable to keep track of it and interact with its api for your automation or if you just keep everything in a well structured database

wide nest
#

@cloud spruce Thanks. I was also thinking of keeping the 25g at the bottom of the stack.

thorny solstice
#

i cant find any good documentation on the scapy library does anyone have any links

cloud spruce
elder cobalt
#

um @cloud spruce does this code make any sense or do you think there might be ways to improve on this?

errant bayBOT
elder cobalt
#

Just so to let you know I'm trying to first use a filter in the pydivert.WinDiver to filter out server packets being sent to me and client packets sent to server, what I'm trying to achieve is sort of like to keep teleporting into other players but in reverse I've somewhat achieved it but I can't seem to like keep let's say 5 meter distance in front of my car, when I do data[6:10] = struct.pack("<f", struct.unpack("<f", X_pos)[0] + 5) so that the teleported car stays in front of me 5 meters it works until I start facing my car the other side and the teleported car goes back to my rearview mirror instead in the front of the car

#

any idea what could be up to it?

#

Session_ID's is used to identify players in a given car

#

I want to sort of like mirror my car's driving so far I could mirror it's X rotation so that the teleported car is inverted but I can't for some reason make sure the teleported car stays in front of me at all times

#

also at some instances I get an error saying that X_pos is not defined, but when I re-execute again it starts working I assume it might be because of how I implemented the logic?

elder cobalt
#

I guess in short how do you make like a mirror? @cloud spruce some sort of a mirror which is in a fixed length/distance apart from the first car?

#

Can't seem to visualize an idea for this because

#

If Car A was at (1,1) I want Car B to be at (6,6) in an XZ plane but if car A starts to turn/rotate entirely basically facing the opposite side and maybe if the position changes to (-1,-1) then car B should be at (-6,-6)

elder cobalt
#

feel like I'm getting lost as I proceed

cloud spruce
elder cobalt
cloud spruce
#

sounds like your implementing some kind of spectator mode

elder cobalt
#

because I get errors saying that

#

and I need to keep restarting until it starts working

#

might be because of this

#

but not sure what else can I replace it with?

cloud spruce
elder cobalt
#

when I put a print statement at the very top it sends 4 packets from server, then followed by a 62 which is a client packet

#

Could it be it's suddenly jumping to the elif statement for client packets ?

#

and since it hasn't decoded a server packet the client does not know X_pos?

cloud spruce
#

you know the server port, right?
use that for your comparison

elder cobalt
#

it's mostly udp as well

#

because if I were to include the port alone then I'd need to again create an if statement for checking if it meets a certain payload length

#

included debug prints

#

so it's sending stock server packets but then for some reason when it changes to 62 it says X_pos is not defined

cloud spruce
elder cobalt
cloud spruce
elder cobalt
#

oh no issues

#

👍

#

still confused over why once I receive a client packet the whole thing breaks

#

it would make sense if my first packet was a client packet and then it starts breaking since then I haven't received a server packet

#

speak of the devil lol

#

I feel like I need to maybe sort of first query server packets and then after I have some readable ones then pass it to X_pos?

cloud spruce
elder cobalt
#

it's just a guess but maybe

#

I tried putting a print on the server packet as well

#

so maybe nothing is being assigned at all to X_pos?

#

I guess that should mean that it's basically jumping to client packets

#

without decoding any server packets

#

🤔

#

yeah xd after assigning a variable in the client for X_pos next error came up saying Y_pos is not defined

cloud spruce
# elder cobalt

yeah, i don't really see why you would use data from the server packets and shove it into the client packet
is that to mirror (with modifications) the actions of another session_id then your own?

elder cobalt
#

idk I feel like I should maybe start from scratch and maybe this time create my functions?

#

Kinda glad I got it somewhat working but still far away lol

cloud spruce
#

haha, i think i just committed a sin on this server 🤪

#

on this server Python is always the best tool for the job 😉

elder cobalt
#

Idk how else should I proceed, maybe make a check to see if there's any payload being returned? But then if it's not then what would the client do? Continue normal until it starts recieving packets from server to swap or keep looping the server packet function till it gets some payload from it?

#

a bruh

#

so its expected to have a variable defined

#

@cloud spruce huh I seem to have fixed it?

#
elif len(packet.payload) == 62: # Client packets
            data=bytearray(packet.payload)
            #print(len(packet.payload))
            try:
                data[6:10] = struct.pack("<f", struct.unpack("<f", X_pos)[0])
                data[10:14] = Y_pos
                data[14:18] = struct.pack("<f", struct.unpack("<f", Z_pos)[0])
                data[18:22] = struct.pack("<f", struct.unpack("<f", X_rot)[0] + 3.14159)
                data[22:26] = Y_rot
                data[26:30] = Z_rot
                data[30:34] = X_vel
                data[34:38] = Y_vel
                data[38:42] = Z_vel
                # data[42:43] = tyre_fl
                # data[43:44] = tyre_fr
                # data[44:45] = tyre_rl
                # data[45:46] = tyre_rr
                data[46:47] = steer_angle
                data[47:48] = wheel_angle
                data[48:50] = engineRPM
                data[50:51] = gear
                data[51:55] = statusFlag
                packet.payload = bytes(data)
                w.send(packet)
            except:
                NameError
        else:
            pass
#

didn't knew all it needed was a try statement 💀

#

spent like a whole day on it

cloud spruce
elder cobalt
#

it's like saying yeah that piece of code will have

#

errors

#

but still run it

elder cobalt
#

it looks like you use except to catch all types of errors

cloud spruce
#

you should not catch all types of exceptions, instead be as specific as you can

#

but instead of pass you probably want to handle it in some way, for example log a message about it

elder cobalt
#

I assume like this?

cloud spruce
elder cobalt
#

I guess the next hurdle is now

#

making it mirror

#

already losing hope lmfao but imma start it tomorrow morning

elder cobalt
cloud spruce
# elder cobalt making it mirror

if you want to have the object always be 5 meters ahead of the nose pointing at the nose regardless of where the nose points you need to do some math, more specifically geometry

cloud spruce
cloud spruce
elder cobalt
cloud spruce
elder cobalt
cloud spruce
iron trout
#

Hi everyone ! I was playing with a python API, and I wanted to change a python command in html command : the command is "request.post(site, arg1=value1, etc)". I would like to know how I should manipulate the arguments of this function for making it a link pls : )

elder cobalt
iron trout
cloud spruce
iron trout
#

oh thx dude !!

cloud spruce
urban spire
#

Do you program directly with sockets or is there simpler native modules?

cloud spruce
granite loom
#

Does anyone know an oauth 1 module for httpx? I tried authlib but i need a realm key in my oauth header and authlib doest support that even tough it says in the docs it does.

elder cobalt
#

I guess I found some relation with rotation and position of X axis but not sure @cloud spruce

#

-X pos means +X rotation? so if my X position keeps decreasing I need to subtract in order to stay in front?
+X pos means -X rotation? so if my X position keeps increasing I need to add in order to stay in front?

cloud spruce
cloud spruce
elder cobalt
#

@cloud spruce ```python
if struct.unpack("<f", X_rot)[0] < 0:
print("Positive X")
data[6:10] = struct.pack("<f", struct.unpack("<f", X_pos)[0] + 3.5)
data[14:18] = struct.pack("<f", struct.unpack("<f", Z_pos)[0] - 1.75)
elif struct.unpack("<f", X_rot)[0] > 0:
print("Negative X")
data[6:10] = struct.pack("<f", struct.unpack("<f", X_pos)[0] - 3.5)
data[14:18] = struct.pack("<f", struct.unpack("<f", Z_pos)[0] + 1.75)
elif struct.unpack("<f", Z_rot)[0] > 0:
print("Positive Z")
data[6:10] = struct.pack("<f", struct.unpack("<f", X_pos)[0] + 1)
data[14:18] = struct.pack("<f", struct.unpack("<f", Z_pos)[0] + 5)
elif struct.unpack("<f", Z_rot)[0] < 0:
print("Negative Z")
data[6:10] = struct.pack("<f", struct.unpack("<f", X_pos)[0] - 1)
data[14:18] = struct.pack("<f", struct.unpack("<f", Z_pos)[0] - 5)
else:
pass


Is there anyway to like combine Positive X, Negative X, Positive Z and Negative Z into one whole group? so far after testing a bit it looks like I can only get it to work for north and south but not east and west
cloud spruce
elder cobalt
#

it sucks that there's no way to indicate if it's facing north south east and west it's all a huge guess work

#

-X pos means +X rotation?
+X pos means -X rotation?
-Z pos means -Z rot?
+Z pos means +Z rot?
This is just a huge guess work so I'm sure if I were to try this on any other map it'll fail

cloud spruce
elder cobalt
#

idk I'm really bad when it comes to math 😅

cloud spruce
# elder cobalt idk I'm really bad when it comes to math 😅

i really need to know what version of python you have to be able to write this in a good way
and if you would be able to upgrade to a newer version (preferable) if it's a too old of a version to work with all the features i was going to use, or if i would need to write the code for an older version of python

cloud spruce
# elder cobalt Python 3.9.2

i think 3.9.x will be just enough for what i was planing to write (as i was planing to use some language features first introduced in 3.9) 👍
for better exception handling in other parts of your code you might want to move to 3.10.x (if you can), for example to be able to find the variable name that isn't defined yet in your code using my example above:

try:
    ... your code here ...
except NameError as e:
    print(f"{e.name} isn't defined yet.")
```but it's not required if you are fine with sticking with the normal error message
then can you keep 3.9.x and do:
```python
try:
    ... your code here ...
except NameError as e:
    print(e)
elder cobalt
cloud spruce
cloud spruce
cloud spruce
# elder cobalt idk I'm really bad when it comes to math 😅

let's have fun and do some math 😉
what we need is a branch of geometry which is called trigonometry which is very useful when dealing with 2D and 3D space
first i though that i would just give you this little function:

import math
def relative_position_2d(distance: float, rad_angle: float) -> tuple[float, float]:
    return distance * math.cos(rad_angle), distance * math.sin(rad_angle)
```but then i took the liberty to rework your code "a bit" (but since i don't run windows and don't have the game i can't really test the code for errors): https://paste.pythondiscord.com/atutakofen
i think there is still more that could be done to improve up on it, but i think this is at least a start
elder cobalt
#

👍 will try it out

elder cobalt
#

if we were to do 1+2 it'd be data[3] meaning it'd print the first 6 bytes, I'm thinking of only printing the one starting from 1st and ending at 2nd

#

so [1:2] for stock, [3:4] for modded

cloud spruce
# elder cobalt so [1:2] for stock, [3:4] for modded

in python [1:2] == [1], so if you want the second and third element/byte (as the first element/byte is numbered 0) for the stock server
if you want both those bytes is should say [1:3] to get the second [1] and third [2] elements/bytes, as this is very different from many other languages where it's inclusive it can be a source of error if you originally come from other programming languages

elder cobalt
#

o i see

elder cobalt
cloud spruce
#

i might have changed too much without being able to test the code 😅

iron trout
elder cobalt
#

btw I see it says if data[1+offset] != session_id will it avoid the whole statement below?

cloud spruce
elder cobalt
#

like assigning X_pos, Y_pos and Z_pos?

cloud spruce
elder cobalt
#

this is like my current world position

#

keeps teleporting everyone on the air

cloud spruce
# elder cobalt

oh, right, otherwise pydivert will not deliver the packet at all 💡

#

that would be a big problem indeed, i forgot that we are diverting the packets with windivert

elder cobalt
#

also shouldn't we be messing with X and Z position coordinates only?

#

I want the Y level to be the same as the car I am copying

cloud spruce
#

this line just copies the Z_pos of the target car in to yours, so you should be on the same level as the target car (regardless of the elevation of the course):

data[14:18] = Z_pos
elder cobalt
#

but elevation in game is Y axis?

cloud spruce
#

so you could end up in the air or under the road if it changes elevation

#

oh, i though that was Z

#

then we should just change some code

elder cobalt
#

would this much of a change be enough?

cloud spruce
#

i didn't read your comments in the code careful enough

elder cobalt
#

a no issues

cloud spruce
#

that should correct that problem 😄

elder cobalt
#

Let me try printing it's coords and check

cloud spruce
# elder cobalt btw I see it says if data[1+offset] != session_id will it avoid the whole statem...

instead use this:

        if packet.direction == pydivert.Direction.INBOUND:
            if len(packet.payload) == 61:  # Stock server packets
                offset = 0
            elif len(packet.payload) > 63:  # Modded server packets
                offset = 2
            data = bytearray(packet.payload)
            if data[1 + offset] == session_id:
                X_pos = data[9 + offset : 13 + offset]  # Checking X_pos (front/back)
                Y_pos = data[13 + offset : 17 + offset]  # Checking Y_pos (up/down)
                Z_pos = data[17 + offset : 21 + offset]  # Checking Z_pos (left/right)
                X_rot = data[21 + offset : 25 + offset]  # Checking X_rot (front/back)
                Y_rot = data[25 + offset : 29 + offset]  # Checking Y_rot (up/down)
                Z_rot = data[29 + offset : 33 + offset]  # Checking Z_pos (left/right)
                X_vel = data[33 + offset : 37 + offset]  # Checking X_rot (front/back)
                Y_vel = data[37 + offset : 41 + offset]  # Checking Y_rot (up/down)
                Z_vel = data[41 + offset : 45 + offset]  # Checking Z_pos (left/right)
                tyre_fl = data[45 + offset]  # Checking angle of tyre fl
                tyre_fr = data[46 + offset]  # Checking angle of tyre fr
                tyre_rl = data[47 + offset]  # Checking angle of tyre rl
                tyre_rr = data[48 + offset]  # Checking angle of tyre rr
                steer_angle = data[49 + offset]  # Checking steer angle
                wheel_angle = data[50 + offset]  # Checking wheel angle
                engineRPM = data[51 + offset : 53 + offset]  # Checking engine RPM
                gear = data[53 + offset]  # Checking current gear selected
                # Checking Status flag of car (eg: - Brake light, head-light, indicator & etc.)
                statusFlag = data[54 + offset : 58 + offset]
                has_data = True
                packet.payload = bytes(data)
            w.send(packet)
#

for the first if statement that is

#

since i forgot that we needed to reach the w.send(packet) line for the packets to get delivered from the server to your client instead of just being droped

cloud spruce
cloud spruce
elder cobalt
ember ledge
#

anyone have any knowledge about machine learning

#

UwU

ember ledge
cloud spruce
ember ledge
#

maybe

cloud spruce
#

yeah, kind of, it was a generalization/simplification

ember ledge
#

so basically i bought a course

#

i learnt one thing but idk what it will b used for

cloud spruce
elder cobalt
#

btw I'm getting these errors should this fix be enough?

ember ledge
#

its annoying pftlemon_angrysad

cloud spruce
cloud spruce
elder cobalt
#

a its fine lol

#

its like really small errors

iron trout
#

Like the one u paste in google

elder cobalt
#

so this is my current game coords, this is what the teleported car is sending 🤔

#

woops

#

disregard that post

cloud spruce
#

that looks very wrong

elder cobalt
#

forgot to change my session_id

cloud spruce
#

ah, hahaha

elder cobalt
#

yeah this is what the teleported car is sending

cloud spruce
#

looks like it would be jumping around a lot 🤔

elder cobalt
#

for some reason the Y axis keeps changing alot as well

cloud spruce
#

we aren't modifying it, so it shouldn't 🤔

elder cobalt
#

this is basically capturing Car B's Y axis(not the one getting teleported)

#

I guess I'll just name it as Car A the one teleporting and Car B which is stationary or my dummy subject

cloud spruce
#

do we really have the correct byte offsets for all the fields?

elder cobalt
#

pretty sure we should

#

data[13:17] is Y position

#

so since its a stock server

#

data[13+0:17+0] offset is 0

#

is this block correct?

prisma cobalt
#

@elder cobalt out of interest, how are you sending the binary floating point data over a socket?

elder cobalt
#

not creating my own sockets xd

#

basically it does the job of opening sockets and changing values before sending over to the network stack

#

and I convert float to bytes

#

IEE 754 float values to be precise

#

the game I'm fiddling with uses little endian might be different for other games

#
    for packet in packets:
        if packet.direction == pydivert.Direction.INBOUND:
            if len(packet.payload) == 61:  # Stock server packets
                offset = 0
            elif len(packet.payload) > 63:  # Modded server packets
                offset = 2
            data = bytearray(packet.payload)
            if data[1 + offset] != session_id:
                packets.send(packet)  # this packet wasn't for the right car
            X_pos = data[9 + offset : 13 + offset]  # Checking X_pos (front/back)
            Y_pos = data[13 + offset : 17 + offset]  # Checking Y_pos (up/down)
            Z_pos = data[17 + offset : 21 + offset]  # Checking Z_pos (left/right)
            X_rot = data[21 + offset : 25 + offset]  # Checking X_rot (front/back)
            Y_rot = data[25 + offset : 29 + offset]  # Checking Y_rot (up/down)
            Z_rot = data[29 + offset : 33 + offset]  # Checking Z_pos (left/right)
            X_vel = data[33 + offset : 37 + offset]  # Checking X_rot (front/back)
            Y_vel = data[37 + offset : 41 + offset]  # Checking Y_rot (up/down)
            Z_vel = data[41 + offset : 45 + offset]  # Checking Z_pos (left/right)
            tyre_fl = data[45 + offset]  # Checking angle of tyre fl
            tyre_fr = data[46 + offset]  # Checking angle of tyre fr
            tyre_rl = data[47 + offset]  # Checking angle of tyre rl
            tyre_rr = data[48 + offset]  # Checking angle of tyre rr
            steer_angle = data[49 + offset]  # Checking steer angle
            wheel_angle = data[50 + offset]  # Checking wheel angle
            engineRPM = data[51 + offset : 53 + offset]  # Checking engine RPM
            gear = data[53 + offset]  # Checking current gear selected
            # Checking Status flag of car (eg: - Brake light, indicator & etc.)
            statusFlag = data[54 + offset : 58 + offset]
            has_data = True
            packet.payload = bytes(data)
            packets.send(packet)
cloud spruce
prisma cobalt
#

cool thxs

cloud spruce
# prisma cobalt cool thxs

the reverse is just (the last [0] is because unpack returns a tuple that we don't want here):

def to_float(data: bytes) -> float:
    return struct.unpack("<f", data)[0]
elder cobalt
#

I have a bad feeling that the Y axis might be capturing something wrong?

#

hmm offsets

#

uhh xd

#

data[14:18] is Z axis

#

br moment

#

not sure why Y was there

cloud spruce
elder cobalt
#

yeah pretty much

cloud spruce
#

so, might be fine if you just fix that 🙂

elder cobalt
#

oh wtf