#networks
1 messages Β· Page 47 of 1
Was thinking if I could refit some parts of your code in mine (basically the modded server part only) but guess it'll take a bit more time to understand first lol
Thanks
try running it as-is and see if it works as intended π
if you just want to test the code without moving your own car you can use the --no-teleport option on the command line, and you might want to add one or more verbose options like -vv to see what it's doing or would have done if it would have teleported your car
@elder cobalt just wondering of the code works or not
after working on it so long it would be fun to know as i couldn't test it for real π
Ah I'm sorry since I'm heading to bed early today as I've got my enterance exam tomorrow, but I'll give you feedback after I'm done with it
ah, i see, yeah, you should definitely prioritize your exams in that case
good luck with your exams tomorrow then π€
π thanks alot
Hi everyone
i have a problem with my dns can i ask my question here? (i mean is it the right channel xd)
ask your question and see if anyone can help
Alright ... so i have a problem with my dns when i connect to a specific wifi (lets call it wifi-x)
My dns works fine when i connect to another wifi and the dns of other machines works also fine when they connect to that (wifi-x)
I'm using kali linux ... i really tried all the solutions i found on the internet but nothing changed π€·ββοΈ
Any ideas of what causes this problem?
IIS can only handle HTTP. They have a Network Load Balancer for layer 4
i'll leave a shorter version here for you as well: https://paste.pythondiscord.com/zarirujehu.py
it's without any of the mocking and a little bit less debug output available at high verbosity levels
the line if __name__ == "__main__": and after is just for handling command line arguments
and gathering some variables and values for the script, besides kicking of the main() function
you are overwriting the conv2hex variable over and over again in the loop
conv2hex will only contain the hex encoded equivalent of the last element of wordlist
!e
wordlist = ["POST", "scripts", "Plugin"]
for x in wordlist:
conv2hex = x.encode("utf-8").hex()
print(bytes.fromhex(conv2hex).decode('utf-8'))
@cloud spruce :white_check_mark: Your eval job has completed with return code 0.
Plugin
later in if conv2hex in data.hex(): you also only check against one string
you need another kind of construct here too
Hello, just returned back from exam, wanted to know how would it be possible to check against multiple wordphrases? As of now I'm recieving http packets and trying to filter them out by specifying POST, or if one of the http packets contain scripts, Plugin it'll filter them out as well
I might be increasing the world list so I think it'll be convenient if i could just add in words in the word list and it'll convert them to hex automatically and check the data stream if it matches to anything from my wordlist
i'm hoping your exam went well
converting the payload of every packet to hex is quite wasteful, even making a bytearray of every packets payload is probably unnecessary
i think you should rather just convert each element in the search list to bytes and then prepare them for efficient searching, then using that to search the bytes of the payload of each packet
there are numerous algorithms you could use for the efficient searching for the different terms
are you interested to know how many of the words matched and where in the payload or just the first match and which it was or even just that one of the words matched and no regards to which it was and where in the payload?
and i think you will notice that filtering http traffic like this is very ineffective in the almost "only https" world of today
also, different types of data encoding and character encoding can be used in the data stream to easily bypass such a filter
These are all the http packets which are being sent from my client to the server here's an example. I just want to block these get requests from my client using a keyword filter
aha, the game client just uses http? π€¦ π
Yeah the game sends http packets at first requesting for server info like time, players online and etc. After that the server responds back with it but when I'm loading in-game right before it finishes loading in fully it'll load these scripts. After that it switches to sending UDP packets
Unfortunately there's no way for me to disable it other than doing it with packets
Hello @cloud spruce would this be efficient?
wordlist = bytes[b"POST", b"scripts", b"Plugin"]
filter = True
with pydivert.WinDivert("ip.DstAddr = 147.135.137.85 && tcp.PayloadLength > 50") as w:
for packet in w:
data = bytearray(packet.payload)
if filter and (wordlist[0] in data or wordlist[1] in data or wordlist[2] in data):
print("Condition met")
w.send(packet)
else:
w.send(packet)
Also update on the script which you've sent, I sometimes receive really strange values like these @cloud spruce
problem is that I really don't know how to filter out those values, I was thinking if we could maybe filter values if they dont make sense and just reuse the value previous XYZ value? but sometimes car's can teleport to other spawn positions so the XYZ position difference could be too huge there as well
oh hmm
updates come in very rarely
when searching up other sessionIDs
basically it works well for some sessionIDs but not for all π€
I'm still surprised tho how the game client can still understand what sessionIDs those packets belong to
Man it definitely is frustrating
It works so well for some sessionIDs but it does not for others
Is there a way to have N servers connected to each other where each server acts like a client for other N-1 servers.
yeah, i also saw those in the .bin files you sent
i don't really understand what's up with those very large values
i'm beginning to thing that the data shouldn't be accessed as only a full float but that some bits in the data should be ignored and used for something else
sounds like you are talking about a full mesh overlay network of some sort
maybe what you are after is something like a service mesh such as istio or similar?
You'll be in for a bummer 
I've just found out something
That sounds so complicated
I want to keep things simple
So that in whatever order and at whatever timeframe we start our servers, they should get connected the way I want to
yeah?
I have even started implementimg such thing for 2 servers but I'm facing a weird issue
what protocol do you want to connect your servers with each other over?
I posted it here
Tcp
I suggest you to read the question on stackoverflow
You'll understand my problem better
Remember how the server sends velocity in those packets as well? I've kept digging around because sometimes some packets don't contain the sessionID I want. But somehow the game manages to get position of the cars picture perfect.
Discussed with someone and he said that there was a reason behind the game sending velocity values and that it's because the game uses it to predict the car's position with velocity packets but when I asked whether if let's say the client sends a XYZ position and velocity packet, will the client still keep predicting or use the new packet which it has received and maybe smoothen out the values so that it does not look like the car teleported but unfortunately no clue about that
i did, but i also see it's c++ and not python, it's been many years since i read (not to mention wrote) any c/c++ at all and i'm pretty rusty at it now
and i don't understand how sniffing comes in to the picture (referenced in your question)
yeah, the client probably use the velocity values to predict where all the other cars will be in between remote updates
the question is if you can somehow affect the client to believe it got a certain velocity as well or if that is all internal to the client, then you might have a problem there as well
It looks like it only uses speed/acceleration to estimate, let's say if the car stops sending in position packets the game will just use the last known information from that car and just predict it until the next set of position/rotation/velocity packets come in
Sniffing is just another raw socket receiving udp packets.... It's doing it's job
Main thing is I'm calling connect() inside the loop continuously until it connects....
And it's non blocking mode
i would think so as well, at least for all the other cars
and i don't see any acceleration information in the packets, so either it's constant speed or based on the difference from the previous packets velocity information for the same session
So my guess is that when connect runs for the first time, bcz of non blocking code doesn't wait but connect() starts doing it's job. And by the time it calls connect() again, the server is already connected so maybe that's why the error?
is this on windows or something else?
because if i remember it right non-blocking sockets on windows doesn't work very well (or at least not as expected)
what I've realised after a few hours in game is that when I spectate other people and they click disconnect the game shows the car's still moving but in one single direction and let's say if the car's approaching a wall or something like that the car goes through the wall (suddenly losing it's collision) and then disappear into thin air later with a message saying so and so client disconnected
yeah, i would expect something like that to happen in such a case unless you can get some notification of a client disconnecting and stops sending packets and act on that
maybe if the client stops sending packets for a minute then it's safe to assume the car's disconnected?
oh yeah
iirc server sends ping packets as well?
probably shorter than that
maybe if ping exceeds 600ms
for your client yes, but you wouldn't get that information for other clients, would you?
server sends ping of other clients as well
yeah, just fired up kaitai to check it too
then it's not worth predicting the player? or it could mean he even disconnected as well if the ping goes really high
hmm can we predict with the velocity field itself?
because if a car stops sending in packets and we were to predict the next position, he could've either increased/decreased his velocity
do you know what unit that is?
it's just an 16 bit unsigned integers
can it be in units of 1 ms or maybe 0.1 ms or 0.01 ms or something like that?
its 1ms
can confirm it ingame as well
{
Vector3 PredictedPosition = CurrentPosition + CurrentVelocity * PredictionTime;
return PredictedPosition;
}
apparently unity uses this function to predict movements
good that it's something sensible
but you probably won't get any more updates if the client just disconnects
yeah that should be just fine, since that's how it happens in game as well lol
yeah, but then you can't act on a to high of a ping value in those instances
Yes windows
yeah that should be fine as well since server kicks out people with uhh >~500-600ms ping
yeah found it
then you need to keep track of time in your code and act on that as well to take care of the case where there are no more updates from the session you are tracking
Oooo fixed my error
By calling connect() only when connection is not there. And i checked status of connection by sending data
You think it'll be possible? π€ sometimes the server sends really weird values but apart from that since that could be easily fixed, maybe to predict we'll just take the last known position and velocity and keep multiplying it with seconds? That way once it gets its new packet it'll take that into account
Oh wait multiplying it by seconds will be a bad idea
If my position was X 1000, and velocity was X 15 and multiplying it by 2 it would be 2030 which is very wrong
you should also be able to check for an exceptional condition of a socket to handle disconnects and other such events
but writing to the socket at intervals is required if you want to detect connection problems that isn't actively announced by the os or the other peer (or device in between)
no no, that would be 1030 as multiplication is always done before addition in math unless overridden with parentheses
so CurrentPosition + (CurrentVelocity * PredictionTime) == CurrentPosition + CurrentVelocity * PredictionTime != (CurrentPosition + CurrentVelocity) * PredictionTime
order of operations are very important π
Hellooo brother
Yes I'm planning to do this in the end of the project
Sooo intially my sniffer sockets were using inadd_any
I've 2 sniffers
Both were receiving all the packets of local ips
But to test some logic I wanted only one of them to receive test packets
So i bound one of them specifically to a local ip say 127.0.0.1 instead of inaddr_any
But even now I'm receiving all the packets on both the sniffer
Whereas second one should receive only for its destination ip
I tried this with 2 of my local ip addresses but same issue
Looks like inaddr_any is functioning even when I've bound to a specific ip
Sorry ignore
I forgot to comment the inadd_any lineπ
Is requests a safe library
Yes.
Ok thanks
Yeah just forgot about the bodmas rule which python follows lol, also is there a way to like store information from packets and reuse them in the event the sessionID is not returning any new updates for X seconds?
we store the data already, but we would need to store som more data too and do som extra checks
also, what action do you want to take when the ping for the target is higher then a set threshold or it has been too long since we saw an update for the target session?
I guess just notify the user about the problem?
And break from monitoring that sessionID?
That way the user can fine tune it
Good news it looks like we need to only predict with velocity and acceleration don't need to take gas, steerangle and those into consideration
you would probably need to set your own velocity to 0, 0, 0, otherwise your car will just continue to travel in the same direction for everyone else
Can't we just assign the velocity value of the target car to the observer? iirc I've tried teleporting to other people in the stock server and at the very first when I didn't mention Velocity the car kept jumping back and forth like it teleports but it kept stopping as well
When I assigned the velocity of my client to copy that of the target it became smooth
Oh yeah I guess I've read this wrong
After a few seconds we can set the velocity back to 0 or just stop assigning values to our velocity
sure, that's what we are doing already
Yeah mb, don't want the car to keep rolling if a car disconnects or the ping is too high lol
i think we need to set all velocity values to zero to stop the car, otherwise it will just continue on its way for everyone else
Hmm that might explain why those cars noclip through walls when my internet dies out or their ping exceeded a certain threshold, maybe at the time of their last packet they might've been somewhere else but because of how our games predicting in our screen it will show the car's going through walls until it notices something went wrong and the car's dissapear
Yeah pretty much
to be able to do this and time out the target as well as doing predictions for updates we would need to do a few more things with the code
This will also explain another thing I was messing around one time with velocity packets, iirc the game was predicting collisions between two cars with velocity so I decided to put my velocity to a huge value to see what happens (whether the game crashes or it'll actually send the person to orbit) when I assigned the same position but +1000 of velocity difference between the actual target car speed and how much I've want I found out that my car kept teleporting way off from the person
So I did a small hack and decided to fine tune position offset values so that when I teleport to a player it'll teleport into them instead of somewhere else on the map and this did work but it was unreliable most likely because of how I didn't take ping into account
there's one thing that has been bothering me though...
how does your client know to change your own view when we are just altering packets on the way out?
that's something everyone else would experience, but not us our selfs since we don't take part of that data since we are just sending it to the server
Yeah your exactly right here the client(for me) would look like I'm sitting still but in reality I've teleported elsewhere
I load up another game client to monitor
No other way π
ah, yeah, that what i was thinking, the client that we are affecting will not get its own updates and hence will not change for it self, just for other players
okay, so you need to run at least two clients for this to work, then that settles it β
The --no-teleport parameter is useful at such instances lol
ah, yeah, but so would just stopping the script, it will just pass the information from the client to the server verbatim
yeah pretty much
Hey guys, I have a small seemingly basic question related to networking
I am trying to find the latency between my friend's PC and the raspberry pi I have at my hand. While both of us could SSH into my raspberry pi, neither could use the ping command using the public ip address in Windows Powershell as it gives us the timeout error:
ping 121.160.xxx.xxx
Pinging 121.160.xxx.xxx with 32 bytes of data:
Request timed out.
Ping statistics for 121.160.xxx.xxx:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss)
Anyone can explain me why?
And if so, how could I fix this problem?
Windows? tracert <ip>
Linux? apt install traceroute and use traceroute <ip>
Thanks
tracert works, but I believe it's pinging to the router, not the raspberry pi
Used the tracerp 121.160.xxx.xxx command
I did port forward the raspberry pi to say port 8000, but using the tracert 121.160.xxx.xxx:8000 doesn't seem to work
It's showing you the hops between the device you're doing it from, and the endpoint.
So it'll go through your network, out your ISP, across the interwebs, to wherever you pointed.
Errrr
Not sure what you mean by that
By "hopping between devices", you mean it pings to each every device connected to the router?
Sorry, I am not familiar with this whole networking thing π
PING and TRACERT (traceroute) networking command line tools (cmd). How to ping websites. How to use the tracert command.
Oh thank you very much
Trying using tracert 8.8.8.8 for example. You'll see the hops and latency between you and Google's DNS server.
Thank you so much @honest pasture
I watched the video and understood trace route alot better
However, I can not be sure as to what ip address should I put in the tracert command.
The aformention ip address of 121.160.xxx.xxx is the public ip address of the router, not the raspberry pi. What should I input if I wanted to ping specifically to the raspberry pi?
Aren't you trying to determine the latency between you and your pal?
If so, you need to tracert to their WAN IP
And their router, which is the gateway for their network should be set to respond to ICMP (ping) packets for tracert to work (I think)
Yes, but wouldn't it be better to find the latency directly from the raspberry pi? Or would that not be feasible/doable?
reminder that tracing routes over public internet is spotty at best, many ISP firewalls do not allow it. Not saying to not use it, just understand it is inconsistent unless you control all interfaces on the selected path that you are tracing
Sure. But I don't know any other solution.
You want to do the traceroute on the endpoint (source) to their IP, sure.
But if that endpoint (source) is on the same physical network, you'll not notice any difference.
Hm
So SSH to your pi and do it from there.
your raspberry Pi is likely only one hop from your home default gateway, it is only going to add mere miliseconds to your overall latency between endpoint A <-> endpoint B
Wow...
I live in South Korea, and my buddy lived in Georgia, USA
We tried this tracert command and found out that the delay is more than 1500ms
This is a problem because my raspberry pi is used to control a robot. Controlling a robot with more than a full second of delay is painful
One hop in particular took up 644ms, traveling from Chicago to Seoul
well, now I will never complain about those emails or confirmation messages taking a while to reach to me
you can't really measure latency with traceroute/tracert, especially not for hops in between
answering traffic destined to the router itself or for TTL timeouts is of the lowest priority for a router and it can even skip it if it has to much other stuff to do
such traffic also hits the control plane of the router, while routing traffic is done directly in the high speed network chips (ASICs and FPGAs) used for the data plane
to get real measurements you need to measure between the two endpoints using another mechanism like dedicated software or the tcp acknowledgement from a service (but not between the two first packets, as the server software might add extra latency before it does an accept() on the connection)
What do you recommend for me to download?
i would probably use something like: nmap --system-dns --traceroute -rn -Pn -sS -p 22,80,443 <host-ip-or-dns-name>
-sT or -sV can be used instead of -sS but i think i got a little lower and more consistent timings using -sS then the other variants
in addition to linux and mac, it's also available on windows where you can opt to install the Zenmap GUI as well if you like to use it that way: https://nmap.org/download.html
there are lots of other tools one can use, i just picked the one that i know works on all those platforms and is still well maintained
another method would be to record or at least observe traffic analyze it with something like wireshark which can calculate round trip times
or write a python script (using scapy, dpkt or any of the other libraries) to do something similar, either live or on a prerecorded pcap file
this method is probably more accurate then just probing a few times and could be used to continuously print a min, mean, max and median value per second or such values and even graph them
looking at the packet data, it got me thinking
if we also copy the timestamp as well as velocity from the target to the observer we should be in sync with the target and not need to predict the new position adjusted for time anymore and just change the x rotation and the relative position as we are already doing, it should just look like we have a bit higher latency, right?
Huh havent thought about this at all, but any reason behind copying timestamp? Since I guess it's only there as an indication can't think of any more uses for it
Also sorry for bringing this up very late but someone already reversed the entire implementation of the stock server and made their own
https://github.com/compujuckel/AssettoServer
Not sure if it could help us figuring out some of our problems regarding prediction but could help here and there
i think every other client with think that we are doing the update earlier and at the same time as the target if we copy the timestamp from the target as well, that way the other clients should see us as moving in sync with the car we are observing and "following" (from in front of it)
i think that can help a lot, because when i was looking at the packets in kaitai i realized that i think the data structure definition file for the modded packets are wrong, and thus we are reading the data misaligned and getting all the data wrong for all the other records but the first in the modded server updates
just check out the data for all the updates other then the first, they are all totally whacked
i'll try something that i suspect might be the fix for that, otherwise i'm going to dig in to the source code from the project you just posted
i just fixed it, the serverMOD.ksy file is missing:
- id: gas
type: u1
- id: performance_delta
type: s2
```after the entry:
```yaml
- id: status_flag
type: u4
```which results in reading all the records but the first one totally misaligned
and i'm beginning to think that it's something wrong with that structure as well, but at least it fixes the other alignment/offset and the data in the other fields for all the other updates in a packet from a modded server
now it looks a lot better in kaitai, and with this change to the code it also fixes the reading of the data and your car shouldn't teleport everywhere anymore:
# Packet structure for messages from server to client
class UpdateIn(ctypes.LittleEndianStructure):
_pack_ = 1
_fields_ = [
("session_id", ctypes.c_uint8),
("pak_sequence_id", ctypes.c_uint8),
("timestamp", ctypes.c_uint32),
("ping", ctypes.c_uint16),
("position", Vector3),
("rotation", Vector3),
("velocity", Vector3),
("tyre_fl", ctypes.c_uint8),
("tyre_fr", ctypes.c_uint8),
("tyre_rl", ctypes.c_uint8),
("tyre_rr", ctypes.c_uint8),
("steer_angle", ctypes.c_int8),
("wheel_angle", ctypes.c_int8),
("engine_rpm", ctypes.c_uint16),
("gear", ctypes.c_uint8),
("status_flag", ctypes.c_uint32),
("gas", ctypes.c_uint8),
("performance_delta", ctypes.c_int16),
]
```i've added the last two fields in that data structure
Unfortunately I'm at bed (around 2:30am here) will change it and give it a try and report back once I get up
i even had this comment in my code since i trusted the .ksy file for the modded server:
# We ignore the last two fields "gas" and "normalized_position" from the
# stock server updates to be able to use the same structure for both
# stock and modded servers, as these fields are not present in the
# updates sent from the modded servers.
oh, that's pretty late, good luck with this tomorrow then π
and it should have said performance_delta (for the packets from the server) instead of normalized_position (which is for packets to the server)
so i guess i messed up that comment a bit
adding the fields to the data structure automatically fixes the alignment due to this code that we already have:
update_record_size: int = ctypes.sizeof(UpdateIn)
```and that i use the variable `update_record_size` everywhere to calculate the alignment and offset
i also think you'll get smother tracking of the target if you copy the timestamp by adding the line:
observer.timestamp = target.timestamp
```just after these two lines:
```python
if args.teleport:
observer: UpdateOut = UpdateOut.from_buffer(bytearray(packet.payload))
and you might copy gas as well with:
observer.gas = target.gas
```just before the lines that reads:
```python
# convert struct to bytes and update the packet payload
packet.payload = bytes(observer)
Hey just doing some testing so far it looks promising, I also found out that if I don't spectate on a player the rate the packets sent to me are very less from that specific sessionID
looks like I guess we don't need to predict stuff π
or we could but I'm not sure
since position is optimised in a modded server, if the player is far away it'll send very very few packets but maybe we could implement a small prediction system here
Anyone have experience with running a UDP socket in the background
Currently I have a GUI using Tkinter and basically I'm sending packets via UDP and I want to receive without freezing the gui
Setting the socket to nonblocking results in WinError 10035
and I tried using after_idle but that didnt work either
Use a second thread
yeah, windows has problems dealing with truly nonblocking sockets unfortunately
you have a few alternatives here, the classical solution is to have different threads, one main gui thread
but that doesn't work as good with python due to the GIL as many other languages, but it might be good enough for what you are doing
you could go multi process, but that will be quite a pain with IPC
or go fully async, but that will require you to change quite a bit of code
i think those changes should solve a howl lot and the prediction should be done for us by the game clients
How can I connect my python flask project to my domain?
it's not so much about connecting anything to a domain as where and how you host your project
so, how and where do you plan to host your flask project?
I also host my Flask project on a domain connected hosting.
"domain connected hosting" doesn't mean anything
i guess what you mean is that you host your domain and site at some hosting company, right?
at least your not trying to host it your self at home, right?
yes yes
My hosting is connected to my domain.
does the hosting company you use support python?
i think it will be hard to help out without knowing what we are dealing with here, is it a VPS or some other form of hosting?
it all depends very much on the platform
if you don't want to tell us which hosting provider you are using i think you should contact their support for help with how to deploy your stuff on their service
i think that the people in #user-interfaces are probably more used to dealing with the GUI toolkits and their event loops
Hmm when I'm not spectating a person and his car is far away I receive his packets less compared to the person nearby, but I haven't tried checking what would happen even with this optimization perhaps my car will appear starting and stopping for the other person, or because now I've teleported to his place because I tricked the game into thinking I'm nearby him it'll start sending his packets like normal or whether it would just predict the path till the next packet is sent
I think the second case might happen, since we've tricked the server into thinking we are nearby him it'll start sending more packets of that sessionID to me
yeah, that is exactly what i think will happen (the second case)
and it makes perfect sense that the server wouldn't need to send as many updates for those further away from each client and much more updates for those closest by
one problem though, your client doesn't know that it's located somewhere else according to the server and the other clients π€
hopefully that doesn't complicate matters
That shouldn't be a problem, I can always load another client to see if it's actually working or ask a friend of mine to screenshare what he sees
As long as we've tricked the server into thinking we are nearby it should be fine
Since the server optimises the packets not the client
That means it's pretty much working now with no issues, if possibly could you maybe go through on how this was possible?
And thanks alot again as well, took a good week or so to get things fixed but luckily we didn't need to do any type of prediction stuff lol
i think that fixing the alignment for the modded server packets and mirroring the timestamp (regardless of stock or modded server) of the target to the observer/spectator was key here
Thanks
i built most of the prediction stuff before i realized the misalignment of all the updates but the first for modded packets and the trick of copying the timestamp to solve the prediction problem and offload it to what is already builtin to the clients instead π
but it wasn't in vain, it was pretty fun to build the prediction stuff
i got to build out the previously very small Vector3 class with a lot more code to be able to write very nice code that does math using that class
At first I thought that maybe because the server is reporting wrong values at times maybe we need to predict it
But it looks like the offsets were slighty off
Fixing that up made things work as expected
yeah, one byte or even one bit off would have skewed things quite a bit, and now it was 6 octets/bytes or 48 bits off, until the alignment was fixed
the problem was that i trusted the ksy file for the modded packet, i guess the old saying "trust, but verify" applies here π
Yeah my bad didn't look through it properly
and i should have looked at it more before just accepting it as reality, so my bad as well
eh at least we knew it was working and only few fields were off
that helped us in rooting to prediction until you brought it up
That there was something wrong with the offsets
everything was skewed and wrong for everything but what i would call the header and the first update, which meant we were pretty screwed trying to work with that until that was fixed
i should have known by just looking at the values of the second and the following updates as well as marking the last field of the last update for a multi update modded server packet and seeing that it didn't correspond even closely to the end of the data of the network packet
Btw @cloud spruce If I want to implement on how you've managed to get modded server packets to decode on other pieces of code I've made you think it would be better to either refit my code or just adjust things in your code in the way I want?
Python supports it. And I installed the software inside the hosting but I don't know how to run it
i think it would be easier to just build on the sorter version i sent you without all the mocking code and just change the parts you need changing or build out that code with extra functionality which you could enable with a few more command line options
otherwise it would be quite a lot of code that would need to be transferred over to your code base
as you can see i'm not using from_float and to_float anywhere
i've even removed those functions entirely as they are not needed any more with the new structs which translates all the data types and fields automatically so that they are easier to work with and in a pretty performant way as well
Alright thanks alot
GOODDAY EVERYONE.. PLEASE CAN Y'ALL LOOK AT THIS AND TELL ME IF YOU HAVE AN IDEA OF HOW THIS WORKS (https://stackoverflow.com/questions/72891994/websocket-connection-closes-immediately-after-it-opens-in-python)
@cloud spruce just a small doubt, if I want to get rid of
def main(args) -> None:
Since I am just going to provide all the variables within visual studio code and change it there, should I just change it to
while True:
or what should I do?
how were you planing on providing the variables in vs code?
and no, there's no need for a loop there
server_ip = ""
session_id = 10
relative_distance = 0
position_adjustment = 0
client_modify = False # Set to false to disable client modifications
verbose = True # Set to false to not print statements.
so I guess I just remove the args statement?
that's one way to do it, but maybe not the way i would have gone with, but sure
also verbose is an integer, so 0 for off, 1 for a little output, 2 for a little more output and so on, at least in my code
In the short version of code you've sent that statement had be changed iirc
For verbose
i've been looking through some of the code of this project
it's really ambitious and quite nice
i also see that my suspicions about the data structure of the .ksy files was a bit off for the last fields
Any other way to efficiently just use the variables I've provided? It looks like below the args statement it's just converting sessionIDs and etc. once for comparing
Yeah regarding the project it took a bit to get things sorted, but it's a huge step up or upgrade from the stock server.
i mean, it must have been a lot of work to reverse engineer and write all that code, it's a really nice and cool project
Took I guess a year or two, finding documentation for the game was next to impossible and the fact that there's no longer any support for the game as well
any networking guru... just curious why I have issues w/ internet connectivity when i switch off my always on VPN on my phone. Is it a dns issue? Sometimes certain apps or sites block the VPN so i need to be able to toggle. Using wireguard protocol
very hard to say with just that piece of information
what device/os are we talking about here and which wireguard vpn client are you using?
my guess is that it isn't restoring all the network settings (like DNS and maybe even default route) properly when disabling the vpn
how long does it take or what actions do you have to take to get it running properly again?
i can just imagine, but really good work on the part of those responsible for writing all that code
Android/graphene OS
Windscribe vpn
But this has happened on mult devices and OS
Idk i usually have to get back on the vpn. So i think youre right in that its a network settings issue
Wish i knew how to just flash it
it sounds like if it's the vpn app that's not doing what it should to restore things on your devices when you disconnect the vpn
i guess it's lack of testing on the part of those how have made that vpn app for the event of people disconnecting
the have probably not tested it enough and mostly tested to get connected and see that that works properly
I will comment to the devs thanks for insight
Can someone help me
i was talking to a person who was a hacker.. and he hacked my friend with an infinite loading gif on discord.. she clicked on it and he had her ip. I went to talk (ik foolishness) and we just talk and he sent normal discord gifs.. i didn't click on anything just chatted .. I'm just scared of the gif.. do u think he has my IP? I have a DHCP enabled Ip
Yeah the code was easy to grasp, I guess you could say maybe because of how the packets are fully reverse engineered it sorta gave me some hope to play around with packets.
does this problem happen both when you disconnect from the vpn and are connected to wifi, as well as when you are only connected to mobile data and disconnect from the vpn, or is it just one of those?
Does your friend or you have a dynamic or static IP from your ISP?
I HAVE DHCP TELL ME ABOUT ME
Yep. So its def networking bs not flushing
if it's a problem for the situation when you are on wifi, you could instead of reconnecting to the vpn try to disable the wifi and after a few seconds reconnect to the wifi again
that should refresh all your network settings for the wifi connection and hopefully it will work just fine again
Well for starters you could just restart your router and say your friend to do the same.
Secondly there's no point in knowing someone's IP address since all the websites you visit know your IP address so it isn't a huge deal apart from knowing where you live and even if they knew that it's going to be very hard to triangulate your actual position.
All I could say is make sure is that if you or your friend have any open ports just make sure to disable and search up a firewall which could filter out those ports just if in case he decides to flood your network otherwise if no open ports nothing much to worry
Im really bad when it comes to finding firewalls which can filter out ports but you can follow any guide online
I have dynamic which means it's changes
yeah, @ember ledge the might know in which city and even which part of the city your and your friend live in, but that should be all
having someones ip address opens up for DoS, but if you connect and reconnect your internet service and you have a dynamic ip you mostly get a new one and that problem should be gone
That might be what your router assigns to other devices connected to your router (DHCP) not the ISP assigning a different IP address to your router
Thank you guys π
No probs just stay safe out there as people sometimes bait you into trying out their new game or something like that lol
you should be safe unless you have opened up ports in your firewall (and then you'll know about it) or clicked something you really shouldn't so that your device is infected
haha, me too π
Mwah
No probs you could go and block + report that person as well as a safety measure
@fast pier one more thing, the same procedure as for wifi should probably work if you're on mobile data as well
just disconnect from mobile data so that you don't have any internet connection on your phone and then reconnect to mobile data again, it should setup your ip address, default route and dns configuration anew
hopefully everything works after that again until you connect to the vpn and decide to disconnect from the vpn again
Btw @cloud spruce there was one line in the GitHub I've posted saying
steerAngle: byte, -127
I assume it's basically converting that field to a byte and doing -127?
GOODDAY EVERYONE.. PLEASE CAN Y'ALL LOOK AT THIS AND TELL ME IF YOU HAVE AN IDEA OF HOW THIS WORKS (https://stackoverflow.com/questions/72891994/websocket-connection-closes-immediately-after-it-opens-in-python)
that just looks like a default value for the data struct to me
but then again i've never learned C#, as i'm not much of a micro$oft person
and it was a really long time since i was doing any C or C++
Ah I see
because when I converted the payload to little-endian unsigned char it went from 0 all the way to 254
or well, looking at the code a little bit more... sure, you could be right
well, that's the thing with an unsigned char, it can only hold values from 0 to 255
at 256 it wraps around to 0 again, you can think of it as var % 256
oo I see
makes sense now why it's at 254 only
I'd expect it to go till 256
1 byte = 8 bits, which gives you 256 different combinations, and starting with 0 gives you 255 as the largest number that you can store before it wraps around or give you an error (depending on the language)
so it should be able to give you 255 as well, not just 254, but it won't be able to give you 256 as that would need a 9:th bit to store that number
0000 0000 = 0
0000 0001 = 1
0000 0011 = 2
0000 0100 = 3
...
0111 1110 = 126
0111 1111 = 127
1000 0000 = 128
1000 0001 = 129
...
1111 1100 = 252
1111 1101 = 253
1111 1110 = 254
1111 1111 = 255
```and then you would be out of bits for a 8 bit (1 byte) unsigned number
```txt
0000 0001 0000 0000 = 256
```with two bytes there would be no problem storing that number regardless of if the data type is signed or unsigned
Oh thanks for the explanation π π
I have 'block connections without vpn' on, so hopefully that was the 'bug' aka 'user error' π
aha, i see, yeah, that makes sense, that would probably give you that kind of problems π
does someone know how I can run a proxy server on my computer and do requests over my computer from a different computer?
I've tried the proxy.py module which didnt let me connect from other computers
like nginx? ( assuming http)
If I enter an unsecured network, how do I know later if my computer is safe?
Hi, I need recommendations on software architecturing. I have a server and a client. The client makes requests to the server and the server responds back with a response. The client is the one that is always initiating the request. However occasionally the server needs to be able to push updates back to the client without the client having initiated anything. How can I acheive this (ideally) without using multithreading? The solution needs to be somewhat scalable (although not too much) and robust and also support sending both binary and text formats.
what OS does the your computer run that you want to be the proxy?
if your computer is even remotely correctly configured the security of your computer or device shouldn't be affected long term by you using a "unsecure network"
however, during the time you are using that network your communications are more exposed and if it's a really hostile network they might try to infect you with something while you are using it
i'm guessing you are going to use http/https, or is this architecture open to other solutions as well?
the client, is it a client device running a web browser or other application or another server as in a microservices architecture or similar?
if the client is the only one that should initiate the connections you can't use something like webhooks as a callback mechanism
you'll instead need to rely on a long lived connection from the client to the server, this can be achieved in many different ways
what you should pick is very dependent on your specific situation, application and environment
with more information we can probably give better guidance
architecture can be http/https but something over plain old TCP sockets is completely fine as well. I only need it to support text+binary formats (i really dont want to use base64), a message based protocol rather than a stream oriented one (the server and client need to send discrete messages to each other) and the behaviour i mentioned above where although the client initiates a request after having connected to the server occasionally the server should be able to "push" messages to the client without it explicitly requesting them. The client is a terminal CLI no webbrowsers are used so the solution shouldnt make any assumptions about the presence of a webbrowser. Throughout the lifetime of thje session the client should begin the connection initiating it and keep the connection open (long lived) up to the point that it ends its current session where the client itself will make the decision to disconnect. While the connection is open messages are passed between client and server. Scalability isnt too big a concern here but it the solution should be able to handle multiple client concurrently with as little resource usage as possible (hence no threads)
currently windows
http/https requests if you mean that
i get httpx.ProxyError and httpcore.ConnectTimeout error
using "ip:port" as the proxy
GOODDAY EVERYONE.. PLEASE CAN Y'ALL LOOK AT THIS AND TELL ME IF YOU HAVE AN IDEA OF HOW THIS WORKS (https://stackoverflow.com/questions/72891994/websocket-connection-closes-immediately-after-it-opens-in-python)
Can you expand a bit more on your setup?
im basically just running python -m proxy and then it starts the proxy server but i cant send a request through it from a different computer (using httpx for it)
I haven't used that module. But from the doc, you could enable debug logging to get more insights into what is going on
maybe that module is just not working? have you setup a proxy server before?
I have setup a proxy server before
what did you use?
squid, nginx (more like reverse proxy in this case), ssh
hmm, maybe that can work for me
there is so many different solutions to choose from and it really depends on the project and your requirements, with so little knowledge of the project i can only touch very broadly on the subject
you could go with something as simple as sockets, but then you would need to add a message protocol on top of that to know when a message starts and ends
or you could go with http/https and using one of all the push technologies that can be used with it, or websockets or even gRPC if you really feel adventurous
or a light wight MQTT like so many IoT devices use, or a heavier message queue with subscription functionality like zeromq pub-sub, rabbitmq pub/sub, redis pub/sub or kafka
you would also need to think about if you require any encryption (https/ssl/tls) and/or authentication/authorization/accounting or access controls
threads aren't that good for io bound applications anyways, i would recommend going with some async library or framework instead
today http/https in some form is most likely the safest bet and is probably more future proof and versatile regardless of what direction your project takes going forward
using http/2 (or even http/3 that was finalized just over a month ago) you can multiplex several client requests and server responses as well as pushed data in parallel over the same connection
but don't use http/2 server push, despite it's name it isn't meant for what you would use it for, instead look at SSE (Server-Sent Events) or maybe websockets
if you decide to go with http/https i would recommend FastAPI (which can be used for more then just APIs) and is an async framework
which ever connection method and protocol you use you will need to think about keep-alive traffic and timeouts
that is, you will need to be sending traffic periodically from either one or both ends to prevent the connection from being removed from state tables in firewalls and NAT gateways and to detect a severed connection so that you don't get "false silence" on the connection
if http/https is all you need there are many proxies to choose from
I would +1 what @ rndpkt is saying.
There is a lot of value in using well known protocols. That means it's well understood, well documented and the tooling and libraries are plentiful
squid being very capable but also kind of a heavy wight if it's just for something simple
for quick things there are simpler more lean software packages to use
@inland sapphire i can just echo the last line from @cunning garden and add security to the list of advantages to using a well studied, understood, maintained and established protocol such as http
could you send me some links?
I figured out what I need more clearly:
connecting to the proxy (username:pw:ip:port) then I want it to be handled like an api that you would build with flask as I want to do another request with the data modified instead of just routing it around and return that.
The most important thing is just that it can be used like a normal proxy you would get from a proxy service
after searching the internet a bit i realize that pre-compiled windows binaries was a limiting factor and that many projects don't carry them for their proxy servers
not even squid had even nearly up-to-date binaries for windows π
if it was me i would want free and open source software, and if it has to be for windows i would like the binary builds to be done by the project it self
so, what's left is:
mitmproxy a well maintained and in certain circles a very well known tool for reverse engineering and... lets just call it "other stuff", and it's written in python: https://mitmproxy.org/
privoxy which is a privacy focused proxy https://www.privoxy.org/ with binaries: https://www.privoxy.org/sf-download-mirror/Win32/3.0.33 (stable)/
i think the first one will be the best for you and cover most of your needs
Thank you for this, I will check mitmproxy out
I could potentially also run this on a linux server as I basically just need a api that acts as a proxy but I am just not familiar with linux
many web proxies are configured without authentication as standard
so all you need to be able to use them is the hostname or ip and the port they are running on
but if you really want authentication to be able to use the proxy you should use the established standard for that
i don't really understand what you wanted to do with the traffic
you will find it hard to read or do any modifications to the traffic as most web traffic today is encrypted using ssl/tls
when running such traffic through a proxy the client uses the connect method to tell the proxy where to connect and then it's just a dumb tcp forwarder to be able to proxy the encrypted traffic
i wanted to use authentication as a way of implementing sessions like many proxy providers do.
the modification i want to do is to act as a a top-level proxy that depending on the session id requests on a different proxy server but since I dont think I got enough low-level control of the proxy servers i wanted to do the proxy requests as an api request basically reconstructing the headers/body to work with the proxy server api and then return the result
GOODDAY EVERYONE.. PLEASE CAN Y'ALL LOOK AT THIS AND TELL ME IF YOU HAVE AN IDEA OF HOW THIS WORKS (https://stackoverflow.com/questions/72891994/websocket-connection-closes-immediately-after-it-opens-in-python)
the requests through the proxy will be made by another api where the proxytype is set to http (not https) so there shouldnt be any encryption?
if it's just http and they don't redirected to you to https (as most sites do), you should be fine and be able to do what you want to do with the traffic
that is also more or less what the mitmproxy software is meant to do, it can even do it for encrypted traffic if you can install your own private root ca certificate on the client that you are trying to investigate the traffic for, unless the client software is really picky about the certificates by using certificate pinning or validates the certificates using the certificate transparency logs
the requests the proxy should do are definitely https but the connection to the proxy not so that should be fine?
i'm really not familiar with all of this, i guess i just have to try mitmproxy out and see if it works for me
no, the connection to the proxy is just clear text at the beginning when the client instructs the proxy where to connect to
then the client will switch to using encryption directly between the client and the server and the proxy is just forwarding the traffic blindly as it's encrypted
but if there is one piece of software that would help you with that it's mitmproxy or burp suite (not open source) https://portswigger.net/burp
but it's more involved when it comes to encrypted traffic
you will need to do a lot more work to bypass the encryption and it will take some cooperation on the part of the client to do so too
if the client is written with high security in mind you will not be able to bypass the encryption without modifying the client software to not make all those security checks, which is a completely different chapter in it self
when the client is sending in clear text to the proxy where the proxy should connect cant i just create a connection with another server instead of the requested one from the client so i can see the encrypted data and once all the encrypted data is received i just do the requests i want to do and return?
no, you would just have the same problem with the ssl/tls certificates unless you can make the client ignore certificate errors (which they shouldn't normally do, since that would open up for attacks)
make no mistake, this is kind of an attack on the traffic and if it was easy to bypass it wouldn't add the security that you expect and require from ssl/tls when you are using the web going about your daily business
i'm sure you wouldn't like it to be simple to break the encryption and have all your logins to all the places stolen and your bank account emptied and people using your credit card to buy expensive stuff online and placing you in debt for it
good and secure encryption is essential in today's society
yeah definitely not but im just trying to find a solution to the limited proxy control i have
bottom line is: if you want to be able to read and/or modify the traffic in such a way that the server would accept the traffic you will need to have some cooperation from the client unless the client is so badly written that it doesn't do any security checks at all and just accept any certificate without any warnings or anything (that would be really really bad)
using a proxy or not is not going to change that fact, you will have to fake the sites certificate and make the client accept the fake certificate in one way or another, against it's better judgement
i have some sort of cooperation with the client so i could be getting it to accept it even with warnings, first of all i need to get mitmproxy able to do https requests instead of them just continuing on forever
then you will need to make mitmproxy generate fake certificates on-the-fly for the sites that the client requests to visit and then use that to decrypt the traffic and then re-encrypt it again with the real sites certificate
this is called a man-in-the-middle (the mitm in the beginning of the proxy name) attack which is used for reverse engineering and penetration testing all the time
ssl/tls is designed to defend against this attack and others under normal circumstances, that's why you should never ever accept/bypass such warnings if you see them when using the computer normally
Okay, I will give this a try tomorrow this is basically what I need and I should be able to get the client to accept the bad certificate
here is the official documentation for this feature: https://docs.mitmproxy.org/stable/concepts-certificates/
and here is a tutorial on the subject: https://earthly.dev/blog/mitmproxy/ (the last section has links to some extra software that might be of interest to you later on)
Btw @cloud spruce just wanted to know, I recollect watching videos where people open proxies with the help of python on another system and then tamper with windows hosts file so that the game traffic or whatever traffic you are interested in will get sent to the PC which has its proxy open and through this people can do packet editing or anything they like
Problem is that if there's a way to proxy UDP packets as well?
Mostly I've seen people only proxy TCP
that's a very special case of proxying and is kind of a variant of transparent proxying, and as such it applies equally to all protocols above the ip layer (such as tcp, udp, icmp, sctp and so on)
the twist is that you would need to know the intended destination of the packets before hand and set the transparent proxy to forward all the traffic unconditionally to that destination
that's because the destination information is lost as the ip address is now rewritten to be the ip address of the transparent proxy host instead
unless the higher level protocol contains a copy of the destination so that one can use that, but that is rare as it is mostly wasteful for a protocol carry yet another copy of that same information
a better way would probably be to mess with the hosts routing table (for a destination that is not on the same network, for hosts on the same network you would need to mess with the arp table instead) to send all traffic for the destination host(s) or network(s) through the transparent proxy host and set up SNAT on the transparent proxy host
that way you don't loss the destination ip address information in the packets and you can inspect and even modify packets before forwarding them to the intended destination
and as you are doing SNAT you would get the return traffic and be able to do the same with that traffic as well
I've noticed that in Windows's host file you could only specify domain names, is there anyway to proxy ip addresses if in case a domain name does not exist?
I'm kinda lost there, because when it comes to domain names you can use the host file to change where to route the packets to but for IP addresses I don't find much information online
that's also a case for changing the routing table (for hosts not on the same network) or the arp table (for hosts on the same network)
i think the routing and arp tables is better to change then changing the hosts file if you want to divert traffic in this way
as changing one of the former two doesn't change the destination ip address of the packets, but changes in the hosts file will
By chance is there any guide as to routing IP addresses to another IP?(Most preferably a VM or a separate laptop?)
so far when it came to proxying I could only think of saying python to open a socks5 port and then use a proxifier app to proxy an app to my socks5 port (it does not have options to use a proxy)
on windows, to look at the current routing table: open cmd and run route print
to modify it: open cmd as an administrator and run something like route add 8.8.8.8 mask 255.255.255.255 192.168.1.50 and you can even add a -p option to the command to make it persistent between reboots, to remove a route again just run route delete 8.8.8.8
[only] for hosts on the same network (does not work for hosts not on a directly connected network) you will have to change the arp table instead:
run arp -a (you can add a -v as well if you want to see invalid entries too) to list all the current entries that are automatically populated using the arp protocol
to modify it you again need to be an administrator and run arp -s 192.168.1.30 01-23-45-67-89-ab where the first part is the ip that you want to modify the arp table for and the second is the hardware/nic/ethernet/mac address of the machine that you want to send the traffic to, to revert the change you can run arp -d 192.168.1.30
the computer you are sending the traffic to needs some special configuration as well to forward the traffic and to use SNAT, on linux that is pretty trivial to set up
Ah I see thanks for mentioning the route add statement, pretty much what I just need. If I'm not wrong if you change your ARP you can technically perform an MiTM?, so maybe if I have a PC & a laptop connected to the same network I could technically speaking make my laptop act as a MiTM that way I can read traffic being sent from my PC
yes, exactly the same goes for both, by changing the routing or arp table on the client you can act as a mitm to watch or modify the traffic to and from that client
and to be able to do the same with the return traffic as well you would need to SNAT the traffic or alter the other peer (or the gateway of the network if it's routed traffic) in a similar way
to make changes to the arp table persistent you would use netsh interface ipv4 add neighbors ... with the information where the ... is the interface, ip address and mac address
or if you want the currently recommended way of doing all of the above you would use powershell (also as an administrator) instead of cmd
and use Get-NetAdapter to get the adapter id for each network interface
together with Get-NetNeighbor, New-NetNeighbor and Remove-NetNeighbor to list and manipulate the arp table
or Get-NetRoute, New-NetRoute and Remove-NetRoute for listing and manipulating the routing table
Ah I see thanks for all the points
maybe a stupid question but can i use the same port as minecraft for multiplayer (25565) for python sockets (for receving data)
not at the same time, only one process can be bound to one port at a time
ok thx
what exactly is it that you want to achieve?
if it's to see the traffic you would set up a sniffer on your machine (or use raw sockets, that is more or less the same thing)
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()
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()
``` any idea why is my server crashing after the first command I give it
Client socket, client address shouldnt be a tuple
I too also use bruh as a standin debug message
what should it be if not a tuple
and bruh is a great standin debug message
just the two variables separated with a comma unpack the variable
:thonk:
connect part
Connect takes a tuple
so where
Your client code is fine
Whats your server code?
why not packing im a du dum
i meant owrking
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()
Oh i think i know
You have to put .accept in your while loop
Otherwise your server never accepts connections ahain
since your client closes
which is bad design actually
because your client is closing it
Socket.close() destroys the connection
You may want to read up on the socket api
thanks @inland sapphire
also I changed it so now it doesnt break it every time
but now its doing the same thing
Wdym same thing?
Once you remove the close() call in client you have to move accept() out of the while loop
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:
client_socket, client_address = server_socket.accept()
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.send("Closing up".encode())
client_socket.close()
server_socket.close()
exit()
if __name__ == "__main__":
main()
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()
You have two accepts in your server code. Remove the one in the while loop
You cant accept twice of your not connecting twice
And you still have a close() in your while loop
This server client code is a mess lol
i highly advise you read up on how sockets work
i read from a book
Itll only take 10 minutes tops and you wont be making these mistakes
the book is trash
Lol
read the python docs they have a short segment on socket fundamentals
at this point your blindly pasting code in based on my suggestions
Yeh just read through that real quick
hi
Guys i just wan to print out this py data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8').split('\n')
but i get this error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81 in position 76: invalid start byte
I can't find a solution
don't have windows, so can't test or help
and this isn't really about networking even if you are calling netsh wlan ...
it's all about string decoding, you might find better help in #python-discussion with this
π€¦ i installed WSL to install python 3.11 only to remember that the whole problem here was testing a windows command
lol
what is Paramiko
Im playing around with a Pi Pico W and trying the use the network lib. I manage to starta a webserver once but whenever i restart my Pico i get this error:
Traceback (most recent call last):
File "<stdin>", line 44, in <module>
OSError: [Errno 98] EADDRINUSE
This is happening when i try to bind the same address again to my socket.
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.bind(addr)
s.listen(1)
I'm following this post: https://www.raspberrypi.com/news/how-to-run-a-webserver-on-raspberry-pi-pico-w/
I can add that i'm doing this in micropython.
i need get get a rasberry pi!!!!! π
hmmm maybe a long shot because i don't have a raspi, but before your s.bind(addr) line can you try add this:
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
wow that seemed to be working. thank you
π
hello guys, was wondering if anyone had any experience making telnet scripts?
can you expand a bit on what you're looking for?
@cloud spruce Hello again π , was doing a-lot of testing and I found out an interesting issue, for some reason using reverse follow and going on maps which have alot of elevational changes the car keeps flying, I suspect target.position.y is supposed to be in play here but I can't seem to figure out why it's sinking even when the packets I'm sending is reaching to my other client at the same time?
could it be because of ping?
where we have to compensate over here? because on maps which are flat it's working as intended
okay it looks like if I comment out + relative_position_x and + relative_position_z although my observer is clipping into targeted car it seems to not fly off this time
I'm thinking maybe there's something more we need to modify with observer.position.y = target.position.y
tbf I don't really know if we manipulate the Y axis alone it would fix the issue, maybe something slightly off within relative position X and Z?
this should explain it I guess?
it's a ssh library for python so that you can interact with things over ssh
i think it will be hard to compensate for as we are not following the ground then it changes elevation, we don't even know anything about the map
as we are "following" in front of the target without knowing anything about the world, we will just pitch and roll with the target
when my target car is behind me, the car keeps sinking
when my target car is in front, the car keeps flying
we are more or less just an extension of the target in front of it, but yeah, we probably should be manipulating the other axis as well
it will never be perfect but it could at least be better
right now we are just adjusing the x and z axis and not the y asis, we probably should, but it will still be strange when a up or down slope ends
hmm yeah
and your "observer" client don't even know what we are doing to it's packets
Btw any idea as to why when I comment out the relative position the car doesn't seem to fly or sink?
Oh yeah it looks like this was an issue before as well for some reason not touching the Y axis but modifying the X and Z axis it seems to fly
not that it moves in the y axis other then what the other car does
but of course it's going to look strange when it has the same elevation as the car it's "following" when it's not in the same position and the ground might be at another elevation
if we can change the y position in a similar manner by looking at the rotation of all the three axis and adjusting our position accordingly along all those three axis it should probably look a little bit better
yeah, it's either we remove the relative position for X and Z (which isn't what we want)
or modify the Y axis such that it has a correlation with X and Z axis?
but should it be a correlation between X and Z axis or X axis + X_relative_position and Z axis + Z_relative_position?
yeah, i think the last option will be the the best, but just remember that anything can be in front of the target, such as a wall, the ground or open air (so that the observer will be looking like it's flying)
yeah thats fine
i think we need to find out which of the y and the z rotation axis is the pitch and which one is the roll axis
for example by looking at how the rotation axis for those two change when you go up hill or down hill on an otherwise quite flat road
oh, is that so?
yep
also good idea, gonna try that now and see how they corelate
luckily I have one of those test grids with elevation changes should help out
at least we can learn if up hill is a positive or a negative change on the axis, depending on which was the axis is pointing in relation to the car, logically it would be positive up hill, but with this game you never know π
alright so I've taken these around -180/180 in-game compass or -0.0/0.0 (rads)
so on flat land
uphill
elevated area
wouldn't uphill and downhill be the same apart from the velocity?
downhill
okay so with Y velocity, if I go uphill my value becomes positive, on downhill it becomes negative (if my car faces the opposite side or if I go in reverse gear)
but I doubt that could help since mountain elevation changes on Y velocity are not really that noticeable
there is no way to see rotation in-game, just position?
in that case it would be good to have data from from the network packets using the script with the --no-teleport and verbosity set to 1 so that we can see the data from there
O hold on
so that we know how the data looks when it's flat and when it's going up hill or down hill
in radians or 180 degrees?
we'll be working in radians i think as it's the native data format in the packets
a bit of a steeper angle in just the pitch direction and as little roll as possible would probably help a lot
great! the data is quite clear at least and is zero based, not flipped 180 degrees as the x rotation was
just for fun, could you put the car with either the left or the right car towards the down hill just to check which way is which on the z rotation axis as well?
for descent my car was placed like this
if I were to reverse descend then it'd be basically this
you mean a car on top here and a car down here?
reverse engineering through raw netowrk packet data π
hmm how do you do this? π€
didn't quite get that
try to turn/rotate the car 90 degrees to the right or left
on the downhill?
yeah
gonna be sorta tricky but will try
can imagine
perfect π
since you have already experimented quite extensively with the compass heading you might know off the top of your head
if going north in the game will take to towards the positive or the negative on the x or the z axis, as well as the same if you go east
i'm already quite sure a higher elevation will take you towards the positive on the y axis
yeah it looks like if your going up Y axis becomes positive
I recollect playing with the Y axis rotation, setting it to 90 degree made my car stand up
hmm haven't tried that out yet
so that i understand the layout of the coordinate system as well as the rotation
sa
okay, maybe another day then
basically you want my car to face the other side?
i just wanted to know if driving towards the north takes to towards the positive or the negative on the x or the z axis when we are talking position, not rotation
and the same question for going east instead of north
nothing with rotation, just position now when you go towards one cardinal direction and then when you go to wards another
i think we got all the rotations down now, now it's just position in the x and z
and if you drive a bit towards that direction?
if you go a little bit further and as straight as you can so that the other numbers don't move so much
okay, so east is positive on the x β π
is this the best place to go for python sockets stuff??
just had to check from which country the game studio originates from since things are a bit weird looking at the packet data, google says italy
i almost though it was from "down under" since things where a bit upside down π€ͺ
sure, ask away π
alright cheers i'll try my best to summarise
basically i'm making a Golden Balls Tv Show clone but im focusing on the networking stuff
def receieve_message():
while True:
command = client.recv(2048).decode(FORMAT)
if command == "VOTE":
round_one_vote = input("Who would you like to remove: ")
message = ("VOTE1 "+round_one_vote)
send(message)
else:
print(command)```
using this to receive data and i'm using this on the server side to send the word VOTE
for client in clients:
client.send("VOTE".encode(FORMAT))```
problem is that sometimes the client prints out "Who would you like to remove:", which is correct, but sometimes it prints out "VOTE" and the client that prints incorrectly seems to be random and it changes each time i run the program
basically just the conditional is breaking sometimes even though every time i run the game the same thing is being sent and each client receives data the same way
clients is a list containing each conn
Iirc the game uses a separate modified game engine
@cloud spruce found it, it's ODE
open dynamics engine
yeah, seem to be the physics engine, but might not be related to the strange coordinate system and data format found in the packets with the 180 degree flip for north and south and so on
cool that it's open source and very freely/permissively licensed
seem like they started out with unity and then moved to write there own game and graphics engine (the graphics part using DirectX 11) and ODE for physics
i really wonder about the networks parts of the game engine, if that is fully home grown as well as the rest of the core game engine or if they based it on something else like they did for the physics part
sorry, don't know the show, but i googled quickly
my understanding is that it's about casting votes on who should be eliminated
so i kind of understand the connection with your software and the general logic
anyways, that isn't required knowledge
but i think you're not showing enough of your code to be able to come to a conclusion of why it's going wrong
and if the top piece of code is for the client i don't see how the input() could print out anything else then what's enclosed in that command to the user
the stuff in the first conditional isn't really what i'm looking to fix, the problem comes from the conditional sometimes not catching that the command is VOTE, yet still printing out the word VOTE
on the occasion that all 4 clients decide to work, the input works correctly (as long as i put valid numbers and stuff like that)
AC was mostly geared towards single player it wasn't really meant to drive with other people, even if you wanted you could only drive with other AI drivers. In short multiplayer in AC had alot of drawbacks to begin with hence we now have new implementations of it
my first knee jerk reaction tells me it sounds like a synchronization problem
that the client and server gets out of phase/alignment with each other
and i'm still wondering how you are handling multiple connections at once
threads maybe? that can be the source of the issue as well if your code isn't thread-safe
my server has threads for individual clients but only for receiving data, sending data is done in the general game code but only when I want to send things in batches
and then each client runs their own version of the code
yeah, that part i was counting on
i would take a hard look at the server threading code
it's generally easier to get bugs in your code when you try to share resources directly between threads
i'd give it a look, but the stuff in the threads isn't really interacting with the error
does the conditional on the client look correct?
this is more theoretical in your case as you are sending such small amounts of data
but you shouldn't trust that client.recv(2048).decode(FORMAT) will return a full line
it could be just one byte or up to 2048 bytes or even no bytes at all for an error condition
well I am trying to deploy a docker container to a bunch of devices through telnet, I need a way to determine whether the download of the container is done instead of using sleep as the downoad time could be different per device
i'm still not sure how telnet plays into this, and what do you mean by a telnet "script"
i am using telnet to login to the device and issue cli commands to deploy the container
and using time sleep in between commands, but for the download, since the time can vary I want to use something else to test whether the docker download is done so it can move onto the next command
if that makes sense
right okay, well in that case on the server side you need to receive the command, start the download and send a further message once that process is done
you need to read from the remote as well as issuing commands
right, the issue is there is no uniform string that is outputted after the docker download is done, it spits out a container id which changes every time
and I cant test for that because it changes
does it have to be uniform?
can't you just send a message once the subcommand has terminated?
thats what I am trying to figure out
sorry I am new to this
how do I know the command has terminated?
do you have any code samples
so you're receiving a command, spawning off something like docker run right?
substring 3 tests for the name of the container within docker ps -a, XXXX is the name
the two minute sleep is completely unnecessary and long but I needed a long enough buffer that ensures completion
and I wish I could use paramiko instead but ssh doesnt play nice
with these devices
hmmm right
do you have a sample output of the docker run command
i think the better way to do this without SSH would be to have a python script running on the receiving end using subprocess and reporting back over the telnet connection when the command has finished and what the exit code is
the issue is, its a router so I cant really run a script on that end of it
the os doesnt allow it
riiight okay
hmmmm
yeah other than searching for a container ID in output i guess you're limited on what you can do there
yeah the output changes for everytime its run
if docker can run then there should be some flexibility in stuff on the end machine
the container ID changes, but not the format of it right?
actually I think the format stays the same
I haven't used Docker in a while so trying to remember what a docker run output would look like
because container IDs will be random but consistent length and format and whatnot
import socket
import sys
from datetime import datetime
portas = [21,80,443,8080,22, 25565]
target = input(str('Target IP: '))
print ('-'*30)
print(f"Scanning Target: {target}")
print ("Scanning started at: " + str(datetime.now()))
print ('-'*30)
try:
for port in portas:
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
socket.setdefaulttimeout(0.5)
result = s.connect_ex((target,port))
print(result)
if result == 0:
print (f'[*] Port {port} estΓ‘ [Aberta]')
s.close()
else:
print (f'Porta: {port} Fechada')
except KeyboardInterrupt:
print ('\n Exit')
sys.exit()
except socket.error:
print ('\n Host not responding:')
sys.exit()
you should also be able to get docker to output JSON
which might make it easier for you
How do I solve this error, the closed doors do not appear and it appears that all are open
Who knows how to solve it, mention me
one sec let me find the output format @cedar forum
π
found this online, this is what it would look like
I dont have access to the devices right now
yeah that seems standard enough, if you get a hash back of that length it's a success, anything else is a fail
a @cloud spruce I tried normalising the rotation of Y axis position, rotation and velocity but it still looks alot more wonky with how it's only doing +1 or -1
I feel like the sinking and floating issue is sorta hard to deal, because maybe at the Y elevation your standing might not be the same for the other car which might be 5 meters in front/back of us so the car might sink or float instead of touching the road
exactly, that was what i was trying to say yesterday, but i think with a few tweaks we can at least make it a little bit better than it currently is
but we will not make it even close to perfect without having both the map and a physics engine to simulate it with, but that would be a way to big of a project to take on for this, at least for me
I guess to overcome that you need to be sort of real close to the car
And not too far away
yeah, the closer you are the less of a problem it will be and the further away you are the more pronounced and obvious it will be
Is there a way to find MX servers without installing a third-party module? Or have smtplib send through MX servers?
To find an MX server? You should already know where your mail server is.
If you want to send email from Python, there's smptd, which is being deprecated in favor of https://aiosmtpd.readthedocs.io/en/latest/
The mail servers recommended by my organization's are "the MX servers for our domain"
I can use smtplib send through that if I give the hostname, which is mxb-something.pphosted.com, but I'd prefer to have my script lookup the current MX and send through that, rather than hardcoding the current hostname which is sure to change
I don't want a SMTP server, I just want to send 1 email from a script
... how often is your MX record changing?
probably often, it is a third-party service
given their autogenerated look I wouldn't be surprised if they changed at least once a year
It shouldn't be changing
That would break your ability to receive emails
Regardless, Python doesn't have a builtin package for DNS, yeah, you would have to get a third party package to check for updated records
We are really getting away from my question but no, of course you can change MX records with no unavailability
you just turn off the old ones after the change
That's a shame, DNS is such a tiny and useful protocol
This is the simplest one I can find - https://stackoverflow.com/a/69403354
You'd just have to change TXT to MX
Now I'm curious though, since smtpd is in the standard library for now, how does it do MX lookups?
oh it doesn't actually send emails
MX lookup is a simple DNS check
in the same way when you go to google.com it looks up the A record to get the IP address, when you send an email it'll look up the MX (mail exchange) server for the domain
they shouldn't change often, it's set by your companies domain administrator, you might have multiple of them
How does smptlib/smtpd get the MX record for a domain?
I actually looked after this question, and it looks like it doesn't? It just opens a websocket on the specified port for the SMTP protocol?
it doesn't
In the OSI model, how do switches know the MAC address of the other system?
smtplib you're responsible for finding the MX and connecting to that
I see
you'd have to use something like dnspython to get the MX record https://www.dnspython.org/examples.html
python doesn't ship with a DNS client, it uses the hosts configuration and syscalls to resolve addresses
every ethernet frame has a source MAC and dest MAC, when a port first goes up and sends a frame the switch will note the source MAC address and add it to the mac address table
the switch has memory as well, so if a port goes down and comes up again, the switch might take an educated guess within a reasonable timeframe that the same MAC is still there
now that does leave the scenario where a switch might not have received a frame from a host yet but receives one destined for it, then the MAC address won't be in the table, so in those situations (which are decently rare), the switch will fallback and forward the packet to all ports connected
every port except the one it was received on, of course
hope that explains it a bit
Thanks! This is my first any bit of networking so just trying to decipher for a bit haha
networking is pretty awesome, good approach familiarising yourself with the different layers of OSI model and the hardware involved π
switch management is pretty fun stuff -- our main switch here, lots of stuff going on
I know that, but Python only exposes getaddrbyname() which only does A
it does, so you need to use something like dnspython to find MX
That it's the same under the hood does nothing for me unfortunately
dnspython is a third-party module
right, if you're looking to keep things solely standard library then you can't find MX records
you could write your own DNS client with sockets but.......
i think that'd be quite a lot of pain for little reward
Yeah I considered it honestly π
yeah, either include a third-party library like dnspython, it's good, ive used it a lot
or implement your own, which might sound like a small task for the simplest bits, but it's larger then you probably imagine, lots of rfc:s if you really want it to work
for example, when the response is to large to be able to deliver in one dns udp frame you will have to switch to tcp regardless of if you want to or not
even if the third-party library isn't available in your environment you can include it in your project instead
dnspython depends on Cython
ah, right, if you are in a very constrained environment you might look for a pure python implementation instead
it looks like here is a few async/aio implementations out there for dns that are pure python
What is a port? Is that the TCP and UDP?
A physical port on the switch, that you can plug a cable into
Oh haha
What's an ethernet frame?
I saw that it's something on the data link layer that can hold things including the source and dest MAC addresses yea?
an ethernet packet
whats a websocket?
when a port first goes up and sends a frame the switch will note the source MAC address and add it to the mac address table
So when you physically connect a port to that switch, the port sends out an ethernet frame that reads the source MAC address I assume
WebSocket is a protocol built on top of HTTP that can do bidirectional communication
https://en.wikipedia.org/wiki/WebSocket
can http not do that?
an ethernet frame contains an IP packet, which contains a TCP segment
every time you send a packet on a switch it's contained within an ethernet frame
no, HTTP is request/response only. The server can't send a response unless the client sends a request
ah
yeah, data link is ethernet, routing at the ethernet level uses MAC addresses
could you give an example for what it would be used?
hmmmm alright
awful transparency, sorry for that, but that sums up how the different packets are encapsulated
at the ethernet level it's called a "frame" because there is an actual footer in there, it's not just header then data, it's header, then data, then footer
hence it has been "framed"
Ohh the actual name of the data changes as you add headers to it gotcha
yeah, each layer of the OSI model has a different word to refer to what goes over it
actual packet routing on the internet looks something like this
Im still a bit confused on how the switch gets the, specifically, destination MAC address
each router will unpack the packet to layer 3 to find the IP address (layer 3 is network, IP packets), then use that to find the next hop MAC and repack it
The switch doesn't, it's already in the Ethernet frame that it has to forward
I can see how, in the transmit data phase, the switch can read the MAC address of the host frame, but how can the frame also have a destination MAC address?
just like an IP packet has the source and destination IP addresses put in there by the sender, the Ethernet frame has the source and destination MAC addresses
Yeah, how does the ethernet frame have the destination MAC address then?
computers tie IP addresses to the MAC addresses that packets should go down, for example say that you want to send a packet to 1.1.1.1, your computer will lookup the MAC address of the switch it has to send over and write an ethernet frame with a source of itself and a destination of the switch
I looked it up and the MAC address is like a unique identifier on the NIC of a host computer
so a bit confused on how a frame can get the destination's MAC
ohh ok
The source PC will get the destination MAC address via ARP, https://en.wikipedia.org/wiki/Address_Resolution_Protocol
a frame can't "get" the destination MAC, a computer determines the MAC address it needs to send to and packs that into an ethernet frame
and yeah, that uses ARP
so if you want to send a packet to the IP 10.144.95.1, your PC will first send out an ARP broadcast saying "who has 10.144.95.1, please tell <your PC>"
then the computer that has that IP will reply saying "yeah, that's my IP, here's my MAC"
then the sending computer will put that MAC into an ethernet frame and send it
that's a big simplification of it, because not all destinations will be on the network, so things get more complex when you've got to go through multiple switches and routers, but as a very simple model that's how ethernet frames and ARP work
Thanks!
on Windows, you can see what's in your ARP table using arp -a
Might be a silly question but does the host computer then use that ethernet frame to put the source MAC address in?
if you're sending from A->B, you'll set the source MAC to your own MAC of A, then the dest MAC to the MAC of B, when B gets that and wants to reply it'll flip it around and send a return
Oh cool so A sends its ethernet frame with a source MAC to B, then B writes its MAC on the frame and sends it back to A
pretty much, it's like the return address on a letter you get in the mail
sick sick
ethernet is actually optimized in a way ip isn't, the destination mac address comes first in the ethernet header, while in ip the source comes first
i guess the people that designed ip didn't think of optimizing it as much as the people that designed ethernet and just used what seems most logical for us humans
i think that was kind of a mistake, but whatever
yeah, so the device can take a decision earlier in the data stream
the source is not as interesting when forwarding or receiving traffic
I don't know if anyone would want to take a routing decision from the IP header before receiving the entire ethernet frame
that seems kind of intense, whereas I can totally see switch hardware doing that with the ethernet header
still, you wouldn't need to read as far in to the packet and skip quite uninteresting data
skipping takes no effort at all
you would still have to wait for those bits to come in
and there is such a thing as low latency networking when every nanosecond count
but otherwise it's quite academic
I don't think if the protocol allows for forwarding IP packets before receiving it in full
If you're switching, you can send the exact same frame, but if you're routing you are necessarily changing it
the MAC addresses will be different at least
there are hardware that optimize things outside the specs but the end result will still be as if they followed the specs to the letter
but i guess that is kind of exotic hardware with a price tag that is eye watering for everyone that doesn't require it
It would also limit the features, when routing in that mode you can't make decisions based on TCP port, packet size, etc
GOODDAY EVERYONE.. PLEASE CAN Y'ALL LOOK AT THIS AND TELL ME IF YOU HAVE AN IDEA OF HOW THIS WORKS (https://stackoverflow.com/questions/72891994/websocket-connection-closes-immediately-after-it-opens-in-python)
that is true, i guess it's down to special circumstances and use cases
in some part of fintech there is a race for lowest possible latency
so extrema that companies paid extra money for being in just one or two racks closer to the stock market equipment to get shorter cables
not routing but the do use switching on the ip layer to talk to the stock market systems
that is surprising, given that things like Infiniband are commercially available
at one point they where not allowed to have servers there, only network equipment, so they started using switches with FPGAs and upload code directly to them π
also for having the code run fast by the FPGA and skip the round-trip time back to the company network
Well if they are abusing networks not meant for high-frequency that's something else. I would be surprised if they used ethernet & IP in networks designed for low-latency
nowadays the stock markets in most well regulated markets has a requirement to give everyone the same length of cables within the same data center just so that it's fair
the free market regulating itself is such a farce. If we need referees deciding what is fair and what's not for it to work, it's already failed
they still use eithernet and ip for communication between external parties and the stock market because the stock market wants a unified and well tested boundary towards external parties
yeah, this was decided for outside of the market itself, as long as they could they would sell the closest locations (with the shortest cables) to whom ever would pay the most
you can trust that if there is room for greed there will be someone that takes that opportunity to make a buck
Good paper on the FPGA stuff https://www.xilinx.com/publications/about/ANCS_final.pdf
400Gb/s on a single FPGA
i think this is the fifth time you paste that exact same message where you SCREAM (all uppercase) at everyone ("Y'ALL") to look at your stuff
hmm
yep
!warn @ember ledge don't spam all-caps messages linking to a stackoverflow question. if you are looking for answers, try describe the problem in discord in a reasonable manner.
:incoming_envelope: :ok_hand: applied warning to @ember ledge.
yeah, i need to read that some time, from a first quick look it looks very nice
PP, not seen that before, mostly seen P4 but that might be much higher level then PP
or if this is the predecessor of P4 maybe π€
Please don't be offended by the uppercase letters
The characters are over 2000 so I can't post it directly
summarise it to something lower than that then, upload code samples to https://paste.pythondiscord.com/
Ok thank you.. I'll work on it
Hello folks, I have always been interesting in working on a network project using python but I have no idea on what kind network project to build on my own, any suggestions? I have always been interested in building a low latency project but am not sure if python is the proper language for a low latency project
uhh @cloud spruce I've just noticed in my server logs for some reason when ever I edit packets it starts to spam the logs which it did not before, I found a single code responsible for it so far.
if target is None: # or use cached conversion
# convert partial packet payload to struct and cache it
target = UpdateIn.from_buffer(bytearray(target_data))
these are the server logs
tick tack is a name I've given to another client
I don't understand what the logs really mean here
o fixed it
if client_modify:
observer: UpdateOut = UpdateOut.from_buffer(bytearray(packet.payload))
observer.position.x = target.position.x + relative_position_x
observer.position.y = target.position.y
observer.position.z = target.position.z + relative_position_z
# rotate 180 degrees, or math.pi in radians
observer.rotation.x = target.rotation.x + math.pi
observer.rotation.y = target.rotation.y
observer.rotation.z = target.rotation.z
observer.velocity.x = target.velocity.x + relative_position_x
observer.velocity.y = target.velocity.y
observer.velocity.z = target.velocity.z + relative_position_z
observer.tyre_fl = target.tyre_fl
observer.tyre_fr = target.tyre_fl
observer.tyre_rl = target.tyre_fl
observer.tyre_rr = target.tyre_fl
observer.steer_angle = target.steer_angle
observer.wheel_angle = target.wheel_angle
observer.engine_rpm = target.engine_rpm
observer.gear = target.gear
observer.status_flag = target.status_flag
observer.gas = target.gas
# convert struct to bytes and update the packet payload
packet.payload = bytes(observer)
#divert.send(packet) # Problematic one!
apparently I had divert.send(packet) at the end which was not needed
it all depends on how low of a latency you require
but sure, there might be other languages better suited for very low latency then python
and if you're really looking for low latency your average pc with a normal OS may not even be enough
then you might be looking at a (hard or soft) real time OS of some sort or even specialized hardware such as SmartNICs, NPUs or FPGAs for ultra low latency
on the other hand, do a PoC in python first, try to optimize it a bit and see how far you can get with such a solution, it might just be enough for your use case π
yeah, this would be the perfect place for that, just ask your question here and we'll see if anyone can answer you
good that you found the problem, i had deleted that line of code from the code i sent you and just kept the line at the very end of the for packet in divert: loop block of code that releases the traffic regardless of what it was, it should be the only instance of divert.send(packet) needed in the whole file
Hello, I am using fastapi and I have a post endpoint for user signup and login. I've used pydantic base class for typing the arguments. class has username and password fields only. May I know how do I test this endpoint through postman API? Like where do I add these parameters in postman API?
i think you might find better help with this in #web-development where fastapi is very much on topic
oh thanks I'll post it there
In the OSI model, im a bit confused on which layer exactly data gets sent to the other machine. From what I've read
- Data gets sent in the session layer, e.g. unsure how but apparently you can download files in the session layer.
- Segments also gets sent in the Transport layer, e.g. data transmission with TCP and UDP,
- Packets get sent through routing, where the IP address and mask determines to which network, and subsequent machine the packet gets sent.
However, according to the model, it's more so that data gets encapsulated down the layers until it reaches the physical layer, where the physical layer sends the data to the other machine and the other machine decapsulates the data the other way around.
Just confused on the mental model of data being sent in the OSI model if someone could help clarify, thanks!
it is exactly as you described in the last part there, the model is only about how data gets encapsulated, you can insert or modify data for a particular layer at that layer and the actual transmission between stations (endpoint devices or computers) always happens at the physical layer, the OSI model is mostly a mental model and everything doesn't fit properly in that model
But now im confused as to the point of the different concepts in the different layers. e.g Whats the point the session layer then since it doesnt encapsulate the data?
Was the stuff I dot pointed down, 1 2 3 and 4 not right? Im especially confused about the fact that data is transmitted via TCP at Layer 4.
I suppose if you say everything doesnt fit in the model ill begrudgingly accept that haha
it's a very general and theoretical model, nothing is really transmitted by any other layer then layer 1, the other layers just prepares and formats data before transmission and unpacks and parses parts of the packet on reception of data, many things will mostly just deal with layer 2 (ethernet), 3 (ip),4 (tcp, udp, etc) and 7 (http/https, ssh and so on)
layer 5 and 6 on the other hand isn't as well defined or as separate in most protocols and applications they mostly blend in with layer 7
Id like to get a list of all the IP's my PC is connected to. I was trying with psutil.net_connections() and can pull back a list of lists
z = psutil.net_connections()
for i in z:
for j in i:
print([j])
Which returns the a list information. Below is an example of one of the iterations through j.
[-1]
[<AddressFamily.AF_INET: 2>]
[<SocketKind.SOCK_STREAM: 1>]
[addr(ip='192.168.0.69', port=51721)]
[addr(ip='52.211.92.220', port=443)]
['ESTABLISHED']
[13008]
is psutil the way to capture my 'remote' ip which happens to be j[4] in the output or is there a better library to use?
I discounted using system and netstat
Now days the osi model contains only 5 layers without the session layer and presentation layer.so just be aware of it
the OSI model still contains every layer
you're thinking of the DoD model
or maybe what has been called the TCP/IP model that has five layers vs the four layers of the DoD model or seven layers of OSI
What do you mean remote IP? Public IP? That's the IP your router uses to communicate with the rest of the world
You can see your public IP with
from urllib.request import urlopen
from json import load
with urlopen("https://www.ipinfo.io/json") as response:
data = load(response)
print(data["ip"])
IPinfoβs geolocation API can be used without needing to create an account and without any authentication. That makes it easy to try out and works well for occasional queries. For more serious usage, we strongly recommend creating an account which will provide you with an API token and offers several benefits over making unauthenticated requests.
In terms of latency, something simple, something a normal OS can handle. It doesn't necessarily need to be a low latency project, just something within the network area(if this makes sense lol)
then start with a python project on a normal os
for a bit of performance you might want to look into asyncio and async programming with async/await in python
Hmm alright thanks!
Can you host a websocket server on an ip of your isp? or does some isp not allow it?
that depends on the ISP, but I haven't meant an ISP that disallow self hosting.
So in general, that's feasible
i see, would i need to contact my isp or read something like its tos?
Depends on your country. Reading its tos can't hurt.
But for self hosting, I don't bother checking. I assume I am paying for an Internet connection, not a set of tv channels.
i see, thanks!
No. This is the model that im talking about
i agree with @cunning garden and just want to add that some ISPs will have some filtering, quite commonly on port 25 both inbound and outbound which blocks you from running your own smtp mail server as well as directly communicating smtp servers on port 25 on the internet other then theirs
or you might be behind CGNAT, especially on mobile networks, which will be a hindrance for you to be able to self host anything on that connection without a reverse tunnel to a gateway of some sort (for example hosting a TOR hidden service would still work as long as you can get out on TOR)
but as long as your ip address is reachable from the wider internet you'll probably be fine (depending on laws of the country and region your in as well as possible TOS)
and that is the 5 layer TCP/IP stack/model that i was referring to
and it's even pictured beside the OSI model which is still 7 layers, it hasn't changed a bit
i see, tysm for the info!
Hey Joe,I sent it yesterday
No not the router Ip, which is my gateway ip, I mean the end point of my tcpip connection local machine:port to -> destination:port.
How do you determine a gateway IP?
Like does the gateway IP address follow a certain pattern w the IP addresses of the network devices? e.g. If I have 2 devices on a network with IPS, 10.10.10.10 and 10.10.10.11, with a mask of 255.255.255.0. What would the gateway IP be?
i suggest that you post it (the question and the link to your code at hastebin) here in the public channel
Okay thanks
https://paste.pythondiscord.com/xuvojowetu
Bro here is the link.. I really didn't know how this worked.. before i just saved it and abandoned it.. I thought he was gonna see it or something
The public IP is not the gateway IP. The public IP is what websites and other internet applications see you as
You set the gateway ip, which can also be called the default route. By convention it is normally the first or last ip in your subnet. For example in a 192.168.0.0/24 subnet this would be either 192.168.0.1 or 192.168.0.254
People stop talking about gateway addresses. It's not what I want I want a module I can use to pull remote/public IP addresses from my pc a la netstat.
Also I suggest you redact the second IPv4 address here, it looks like a public IP and people can clog your router with packets
I'm an amature programmer but an infrastructure and cybersecurity professional. There is no accesiable ip I am related to in the post. If you did a ipwhois you would find its owned but someone else
Within a network, does the switch determine which machine to send messages to based on the MAC Address or the IP address of the machine.
Im confused since the part of the IP address that isnβt part of the mask is unique among devices in a network, and so it would make sense for the switch to identify machines based on the IP address, yet I also read that switches use the MAC Address to identify machines
depends on the type of switch, I'd say most switches are layer 2 switches, that's where the devices use ARP to find the neighbour MAC and send that off, then all the switch does is route based on the MAC addresses.
anything where IPs get involved makes the switch layer 3, that's where a switch can perform IP routing operations as well as just switching
Ahh that makes much more sense
So then if switches mostly use MACs to find the machine, whats the point of making IPs unique within a network, e.g 190.190.190.1, 190.190.190.2 instead of making the IPs all uniform
And conversely, if youre using a layer 3 switch whats the use of framing the packet w MACs
MAC addresses can only identify a single machine on a single network that is physically routed, if you're using IPs and applying routing policies then it's a lot easier to use IPs, the way networks work you have a router which says "if you want any IP from 10.144.95.0 to 10.144.95.255 come to me!" and so on and so on until you build a routing table, that means you can route a group of IPs all at once, which you can't do with MAC addresses
IP to IP communication is a chain of MAC to MAC communication at each router
the routing is in addition to the switching, an L3 switch is still doing all the switching with L2 that an L2 switch would do, but in addition is "aware" of IP addresses
Yepp this this makes sense
I need some help with an AWS question. Is it okay for me to ask here?
if it's networking related then sure, otherwise probably #tools-and-devops
It's system design kind of question related to EC2 instances and Auto scaling
I'm preparing for SAA-C02 exam
hey anyone here who uses kali linux ?
I hope that's okay?
First off I'd like to clarify if the router is able to send data to devices WITHIN a network, or if it's only for managing sending data BETWEEN networks?
Hey @cedar forum
https://paste.pythondiscord.com/xuvojowetu
Goodday here's the link
probably more for #tools-and-devops π, fits the topic better
okay thanks
they route traffic within a network (e.g. 10.144.95.1 to 10.144.95.2) or between networks (e.g. 10.144.95.1 to 128.243.46.12)
with a wireless network, all traffic to all devices goes through the router (usually), with a wired network that's the same
the only case it might be different is if you've got a selection of devices plugged into a switch, one of which is a router, in that case, the local traffic can all be handled by the switch, only external traffic will hit the router
So I've got two interpretations of what you're saying haha. Is it
- That by having unique IPs WITHIN a network, when one device sends out a request, it can do so to multiple devices within the network because of the routing capabilities you mentioned
- That from a device within the same network, a router is able to send multiple requests to devices outside its networks at once due to routing capabilities you mentioned
that's fairly common in server networks, so at my job we've got a selection of devices plugged into a switch which use the switch to talk locally, and then a router which lets them talk to the internet, but no local traffic goes to that router
I assume you're saying 1. since it's more relevant to my question and because of what you just wrote haha
multicast (being able to send one packet to multiple devices) is one such example where IPs come in handy, but that's not quite what I mean. basically you should think of MACs as solely being there for device-to-device communication on a physical link (e.g. ethernet, wifi)
anything where a network is being traversed and going through a router is going to be a mix of IP to IP and MAC to MAC communication
say you've got network A which has device A, and network B that has device B
if device A wants to talk to device B then it's going to construct an IP packet with the source of A and dest of B
but the actual transmission will be:
- mac address of device A to router of network A
- mac from router of network A to mac address of network B
- mac from router of network B to device B
Oooh so the MAC address is of the router not the device?
And so you could either have a switch or the router handle sending the transmission from device A to router A and router B to device B yeah?
Depending on your configuration
you can network together switches, yeah, and once you're out of home networks most of the internet is powered by switches rather than routers
Cool, so to reclarify routers can handle the transmission of data based on both MAC addresses and IPs then
routers are L3, so while you communicate with them using mac addresses like you would any device, they're interested in the L3 data because they need to know which MAC to route to next (next-hop) based on the destination IP
In this example, is mac address replacable for any piece of data?
I mean that they're routing based on MAC address
Two different networks, Network A and network B. are able to route to each other using mac instead of IP address?
no, they need to use IP address, because they are not on the same physical link
basically, say you want to access a different network, your device will send that packet to your router, your router will then see "okay, the destination IP is 10.10.1.1" or whatever, it then looks at its routing table to find the next router IP it needs to send that onto (the next hop), then it'll find the MAC address and send it (because they'll be physically wired)
Ohh, so in this example if they network a and network b were wireless, does it go through the same process of finding the IP Address and then the mac?
yes, because network A and B are not the same network, they need to use IPs to route between them
device A will send a packet destined for device B to router A, router A then looks up where to send packets for that network and finds the address of network B
MAC lookup, send data, router B then forwards it to device B
alright lets dive deeper into device A sending a packet to router A
So there are two options,
- there is a switch and it uses the source and dest mac to send the packet to router A, I get this
- If there is no switch how does the router, which we said is able to handle sending data within a network, handle receiving the data from device A
Im confused with number 2
If there is no switch what happens
the router acts as a switch, a router is just a less advanced L3 switch
device A creates a TCP/IP packet destined for device B, then it looks up the next hop that it needs to send to in order to get to device B
that'll be the default gateway most commonly, which is setup when you connect to the router using DHCP
it'll send out an ARP request saying "who has <router A ip>"
it'll get a response, and then it'll send the packet
I kinda get it, and this process you described would be the same with a normal switch instead of the router acting as the switch yea?
Wait up actually no,
with a switch, device A would send out an ARP request for router A's MAC address, then the switch would send the packet to router A.
without a switch, device A sends out an ARP request for router A's IP, then it just sends the packet to router A?
Sorry if im asking a bit too many questions haha all g if you're busy
Hi, i just begun to learn about network, and I am trying to learn a bit about socket, watched some videos, tutorial and tried to work some code, even following the video, but couldn't make it work...
i made a server and a client
yeah p much
it's basically the same process though
but they don't seem to connect
to a device it's no different
Hey @ripe kayak!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Btw why are we referring to the data as packets instead of frames here, shouldnt it be fully encapsulated by the time device a is ready to send it
yeah i'm just lazy with terminology
@cloud spruce Hey, rnd been trying to figure out how to get the Y axis to work but no luck so far π I tried checking if I could maybe make some relation with relative_distance but just couldn't with Y axis..
easy bro
Also just did a bit more digging around it looks like there's a huge issue with not taking ping into account, what I've found out that the results between locally hosting vs joining a random empty server along with my 2nd client was huge. Like when I was messing around with velocity packets and adding relative_position = 100 only for velocity packets but leaving my xyz position coords the same it sorta collides with the car and I'm sent flying but
When I tried this theory on a server with maybe 100ms+ things started to vary, the observer car with only velocity changed was like in front of the car not colliding it sort of looked like it was but it wasn't.
Remember how I mentioned that if I keep xyz pos the same I teleport inside the car? When I tried it on the server it was just following behind way behind me without using relative_position.
You think there's a way to take ping into account?
Or maybe try to compensate ping so that it's the same distance for everyone?
Oh well I guess we've already talked about this before but it looks like you need to do some prediction before hand with timestamps and ping which I am not sure how...
Guys is there any way to do data entry on a mobile app? (esspecially if the app does not have an API avaliable)
What's the best way to receive mail programmatically, preferably self-hosted? E.g. a Python email server
Should I write a program that receives SMTP connections? Do I put that behind a secure server like postfix, as a reverse proxy, similar to how I might put nginx in front of a Python web app?
Do I write a program that reads a mailbox? Or one that talks IMAP?
I can also have postfix etc feed the mails to a script
fwiw, emails are such pain (and often blocked by the ISP), that I would go with a free tier like mailgun (or whatever AWS equivalent) and use the webhook api
Any good suggestions for a networking related project?
Well sending emails seems like a pain because of deliverability etc but receiving doesn't look like it would run into this... unless I'm missing something of course
I'm reading the sendgrid site and I can't figure out their pricing for inbound messages. It's clearly supported though, I have found the API docs
sketchy
hmmm, where's the docs for that
"inbound parse"
huh
just tested this on our account for work, seems to be free
there are no quotas in our billing from what i can see, and receiving a bunch of emails didn't change anything in my stats portal
No free tier? Actually free?
that seems surprising, I mean I might only use sendgrid for receiving... they'll charge me nothing?
Amazon and mailgun charge
I might use that, free is hard to beat. I am already using it to send emails
seems it
no guarantees but
i can't see it anywhere in our billing
guys
i've got a question abou computer science : 'Logical orders'
what is the definition of "XOR"
wait sorry dudes
Hello, I decided to ARP my phone using my PC as the MiTM and it sends requests to my router, when I load up wireshark I can see all the DNS requests going through just fine.
(192.168.0.124 is my phone's LAN ip-address and 192.168.0.1 is my router's address)
but when I launch up pydivert to see if I could edit packets using this code
with pydivert.WinDivert("ip.SrcAddr = 192.168.0.124 or ip.DstAddr = 192.168.0.124") as w:
for packet in w:
print(packet.payload)
w.send(packet)
I only get these on my output?
any idea what could be the issue here? since it shows just fine in wireshark perhaps pydivert is not cut for it?
@elder cobalt Maybe you're not in promiscuous mode?
You want packets addressed to somebody else, you seem to only be capturing packets sent to everyone
I'm in promiscuous mode haven't disabled that, mind sharing how you knew that I'm just capturing packets sent to everyone? Could it be rbfajse of the 255 or is my filtering wrong? Not sure...
SSDP is multicast, 239.* are multicast addresses
O hmm so maybe it looks like my phone sends packets to PC
PC sends it to everyone and then reaches the router?
Then router sends it to PC, PC sends it to everyone and then it reaches my phone?
I've just filtered out ssdp since it looks like my pydivert was only picking that up but wasn't picking these packets which wireshark showed just fine
@cloud spruce if you don't mind can you have a look with this code? https://paste.pythondiscord.com/loraneredu
It looks like I've forgotten to take account BatchedPositionUpdate
https://github.com/compujuckel/AssettoServer/blob/7bdcb4c7634b9c00ab889438919b189212e2e932/AssettoServer/Network/Packets/Outgoing/BatchedPositionUpdate.cs
The only thing different from the original modded server is that if it's not batched the one's highlighted will be the structure of that packet
So I made a new struct and named is as UpdateInB and included or conditions like UpdateIn or UpdateInB but I am not sure if this would be fine?
0x48 identifies as a mega packet
not sure how else could I make a condition over here that if it's a megapacket (batched) don't use the last two fields
then I don't need to include UpdateInB
using the or condition seems to be buggy as well
oh, that complicates things a bit
i haven't had time too look at this much for almost a week now
ah no issues, I'm checking if there's any fix apart from rewriting two separate classes
because then I'd need to create target and targetB π
pretty sure this part of the code is right
elif packet.payload[0:1] == b"\x48": # Modded server version B
offset = 8
for _ in range(packet.payload[1]):
metrics.updates_in += 1
if (
len(packet.payload) >= offset + update_record_size
and packet.payload[offset : 1 + offset] == session_id
):
metrics.matches_in += 1
target_data = packet.payload[offset: offset + update_record_size]
target = None
offset += update_record_size
But **target **and **update_record_size **are problematic (they both have UpdateIn or UpdateInB statement)
so whenever I am printing out the position it works fine for few seconds then it shoots out a random value then goes back to being normal. I tried to just cut off UpdateIn and replace it with UpdateInB everywhere and it worked properly without any of those randomness so there seems to be an issue when I am trying to combine both of these classes with an or statement only
what a mess those last two fields are
in the stock packets it looks to be first performance_delta then gas
and in custom (modded server) updates it looks like it's the other way around
while in batched updates they are not even present at all
so we actually have three different data structures coming over the network only for position updates from the server
and one more structure for position updates from the client, so four in total
Yeah was confusing for me at first but as far as I know I've asked the creator and he said to follow the CSPPositionUpdate.cs struct and for packets which start with 0x46 (which in our case looks like both stock server as well as the modded server sends in version B) It'll have performance delta and gas struct and they will follow a length of 61 (which we had made originally for the stock server but can be used with modded as well) he said when the data/payload starts with 0x48 we have to ignore performance delta and gas and it goes by 0x48,timestamp,ping,counter and then PositionUpdate struct
yeah, much like the custom updates for the modded servers, but without those two fields
do we really need those two fields for anything?
i don't think we really use them from the server update packets
only for the client update packets where we are just copying them verbatim
as in, we are not really modifying those bytes anyways
i'm thinking about just skipping them in the data structure and then hard code the offsets for the record byte length for each type of packet
that would require using a bytearray slice for all but the batched updates in the "mega" packet structure
hmm yeah fair
gas isn't really needed as well as performance_delta
or do you think we will need anything from those two fields for any calculations?
nah regarding that post which I made how my car always used to lag behind
it looks like assigning the target's timestamp the same as mine some how fixes the issue which I am not sure how
yeah, if think that we are copying the timestamp in our code just for this reason
When I assign observer timestamp to target timestamp my car seems to teleport sporadically everywhere
But the reverse works just fine
Decided to yoink in pak_sequence_id as well didn't notice any change but for the sake of it added in
You think timestamp and ping has any relation?
I've searched it online but just couldn't find any post about it