#networks
1 messages · Page 9 of 1
and its open source i may add
no, 5 subdomains of duckdns.org, *.somesubdomain.duckdns.org points to the same ip
Hi, this channel is about computer networks like the Internet, not for the social kind of networking. Also, we do not permit unapproved advertising. Please review our #rules. Thanks.
So I'm learning about sockets and python and I'm wondering if there's a better way of handling errors in the code, rather than writing a bunch of try except statements. Such the following example, to deal with connection reset errors:
while True:
try:
msg_len = conn.recv(BUFSIZE).decode(FORMAT)
except ConnectionResetError:
do_something
break
do_something_else
try:
sth_else
except anerror:
something
break
its a fact of life
what up im new to python
wat up
so i have a TCP server-client application currently running. currently, the issue im currently having is that i need to change the script so that messages from the client will run linux commands like ls on the server.
Client:
serverName = 'servername'
serverPort = 12000
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((serverName,serverPort))
sentence = input('Input lowercase sentence:')
clientSocket.send(sentence.encode())
modifiedSentence = clientSocket.recv(1024)
print ('From Server:', modifiedSentence.decode())
clientSocket.close()```
Server:
serverPort = 12000
serverSocket = socket(AF_INET,SOCK_STREAM)
serverSocket.bind(('',serverPort))
serverSocket.listen(1)
print('The server is ready to receive')
while True:
connectionSocket, addr = serverSocket.accept()
sentence = connectionSocket.recv(1024).decode()
capitalizedSentence = sentence.upper()
connectionSocket.send(capitalizedSentence.
encode())
connectionSocket.close()```
i dont really know how to change much as my knowledge in python isnt good and the professor gave us the script for the server-client beforehand
why don't you just use ssh?
it's a bad idea to let a client execute commands, especially when there's no auth
If someone could help, I'd appreciate it^
How are the network settings configured in your virtual machine?
the virtual machine is Linux Mint running on Parallels. I didn't change any network settings as far as I know, but when I run "ifconfig" on the Linux VM I get a different IP than the one that is getting displayed by the server.
Show the IPs u get
Server is on Mac and Client is on Linux.
Mac
~ > ipconfig getifaddr en0
10.180.187.246
Linux
:~$ ifconfig
enp0s5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.211.55.7 netmask 255.255.255.0 broadcast 10.211.55.255
The vm may be configured using NAT. What virtualizer are u using
Im using Parallels
Right. Never used it but might be worth to look into the network settings. If its using NAT that could be the reason. Change it to bridged or similar if such an option exists
yeah that seems like it might be the problem. Im trying to switch it to bridged right now, thanks
I can send message but can receive it
a powerful website for storing and sharing text and code snippets. completely free and open source.
please holp
so you can send messages and recieve them?
listend to broadcast does not work as intended
been trying some socket stuff for various purposes like multiplayer game dev, cybersecurity projects etc
oh
I need to know why isnt this working
yeah i was goona ask about that too
:incoming_envelope: :ok_hand: applied timeout to @edgy pelican until <t:1701583374:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
anyway the easiest way is with asyncio streams
so
you could do it with threading
but its a huge hassle
clients = []
async def handle(client):
try:
while True:
data = await client[0].recv(1024)
print(data.decode("utf-8")
except ConnectionResetError:
print("ConnectionResetError occurred")
async def main():
server = await asyncio.start_server(
handle, '127.0.0.1', 3001)
async with server:
await server.serve_forever()
``` for the server part @scenic flower
wtf
<@&831776746206265384> sus
dude sent that the second i sent my msg
sorry
i fucked up my selfbot
oopsies
!rule tos
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
dont care
absolute
!ban 897978458163003432 self-bot
:incoming_envelope: :ok_hand: applied ban to @mental mantle permanently.
moment
Why did this dude got banned ?
Asking help for projects is not allowed ?
"this dude" only got muted for 10 minutes, as the message says, automatically by the bot for sending too many duplicate messages in a row. that's an antispam measure and if it triggers when it shouldn't a mod usually unmutes the victim.
So ask help for projekts allowed ?
There's no rule prohibiting asking for help, indeed.
Ok fine
Hey I have done socket programming in javascript before
For websites
lol
I make website and mobile app
certified oops moment
@edgy pelican hey I added async stuff but still it is not working for some reason https://paste.myst.rs/hdyjb6ce
a powerful website for storing and sharing text and code snippets. completely free and open source.
why arey ou using async + normal threading
i cant talk much atm im busy
@lapis lava
now can you tell me
idk i though it was the right thing to do is it wrong ?
whare should I start to learn networking
and would it create any positive impact on my career
and also are there any scopes for the networking
import asyncio
clients = []
async def handle(client):
try:
while True:
data = await client[0].recv(1024)
print(data.decode("utf-8")
except ConnectionResetError:
print("ConnectionResetError occurred")
async def main():
server = await asyncio.start_server(
handle, '127.0.0.1', 3001)
async with server:
await server.serve_forever()``` do this, and change your normal sockets code to use asynciop
it depends really, are you specializing in anything/want to be any type of programmer?
actually I am a first year student so don't know much
wait so undergrad?
I just want to upskill myself
are you an undergrad student
yeah
ah ok, do you want to specialize in anything or be a certain type of engineer?
i am actually doing btech in cse branch so just want to stick to my domain'
oops I made a silly mistake
what does cse stand for
computer science engineering
i want it to be add in my skillls
should I start it
or it willl take me off the road
i'd suggest you learn theory and stuff before
(but then again, im just a random highschooler online, take everything i say with a grain of salt)
what do you mean by theory atuff
like, how it works and things
the infrastructure
ig if you want to
why is this error occuring ? ```py
An unexpected error occurred: object bytes can't be used in 'await' expression
async def listenToBroadcastMessage(clients=CLIENTS):
try:
for client in clients:
receivedMessage = await client.recv(1024)
try:
receivedMessage = receivedMessage.decode('utf-8')
print(f"Message received: {receivedMessage}")
except UnicodeDecodeError:
print("Error decoding message: UnicodeDecodeError")
except ConnectionResetError:
print("ConnectionResetError occurred")
except Exception as e:
print(f"An unexpected error occurred: {e}")
# Handle or log the exception as needed ```
you cant receive bytes in an await function ? is that it ? is there a work around for this ?
@scenic flower see this
you create a new server that you serve_forever(), which specifies a handler for every new client
nani can you explain more please
basically how the server works
is
server = await asyncio.start_server(
handle, '127.0.0.1', 3001)```
creates a server
using handle as the handler
so when someone sends a request
the server delegates the reader and writer to the handler
async def handle(client):
try:
while True:
data = await client[0].recv(1024)
print(data.decode("utf-8")
except ConnectionResetError:
print("ConnectionResetError occurred")```
i do it like this ```py
HOST : str = "127.0.0.1"
PORT : int = 3001
CLIENTS = []
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
server.bind((HOST, PORT))
server.listen(5)
print(f"Listening on server on host {HOST} on port {PORT}")
why isnt it allowing bytes what the reason for that ? @edgy pelican An unexpected error occurred: object bytes can't be used in 'await' expression
try using what i did
oh
i see
@scenic flower the asyncio version uses its own socket library
asyncio doesnt use socket objects
so ?
it uses its own sort
well, you try to await socket.socket.recv(), which isn't an async function. not sure why you think the socket module supports async. you likely instead want https://docs.python.org/3/library/asyncio-stream.html#asyncio-streams

he was originally using sync sockets, but im trying to get him to use asyncio bc dude wants multi-client
nani this just got so confusing in just a few minutes
relatable 😔
damn bro
why do i need to use asyncio when I have the socket library ?
um
so
the normal socket library is "synchronous"
what
basically
you mean we cant write asynchronous stuff ?
when you do thing.recv(...)
the whole program stops
its kind of fixed by threading
but
its janky at best
asyncio is a much better way to do this
because async things have a thing called an event loop
dam i wrote all this code down the drain
basically what it does is its very smart and knows when your program isnt doing anything
so it can do another thing while its waiting on the other thing
I know threading
I mean, you could use stuff like asyncio.to_thread with normal sockets instead, but that's kind of reinventing the wheel compared to using the asynchronous sockets from asyncio.
I gotta do this the right way so I should learn asyncio right for making multi client applications ?
or games or cybersec tools ?
yeah
you dont strictly need to, it'll only save you several hundred thousand million billion trillion quadrillion septillion hours of frustration and pain and suffering and agony
ok thanks a lot man otherwise I would have never know what is the point of socket library if it cant handle asynchronous stuff I mean socket stuff is meant to be asynchronous right ?
this makes no sense
...i mean, what's the alternative? if socket didn't exist at all, what would people do who didn't want async in their networking?
well they can suck it up and deal with it
(one can with some effort make a synchronous implementation asynchronous (e.g. with a lot of asyncio.to_thread) but the opposite direction is more annoying, since you'd have to spawn an event loop just to call an async function.)
lets say you are making something now it needs asynchronous shit and then all the code you wrote is useless
just like me
porting an application to be async is always a lot of effort, really. "Just make it impossible to write non-async applications" isn't really a solution to that 😛
idk man this suks
is asyncio good for making games or cybersecurity tools or websites can I use with react code as well ?
hey come on man help a brother out
really sorry for pinging if you mind then just tell me but I am still hella confused man
please pong me
Asyncio is used in a lot of places. "Cybersecurity tools" doesn't really describe much, but you see it in all sorts of applications. Backend frameworks too, like fastapi. For games I believe it's less common because people prefer to use threading there (because you need low latency in your user-facing stuff, and in asyncio control is only given back to other tasks when the currently executing one yields it).
I am looking for a like-minded people who want to get started with the python with the real time project. If someone interesting learning python right from the beginning, please send me a message
sure
ping me or dm me
will socket library will be used with the asyncio right ?
like to together or are they seprate ?
i mean is one used alongside other
?
me
hey guys I am having some trouble https://paste.myst.rs/j7lomryj
a powerful website for storing and sharing text and code snippets. completely free and open source.
with asyncIO
a powerful website for storing and sharing text and code snippets. completely free and open source.
hey can someone help me ?
what will be passed as sock in this coroutine loop.sock_sendto(sock, data, address)
?
what is sock ?
I am refering to docs but it is clearly not mentioned where to get this value from
Why?
I'm curious as to why they didn't opt to use nonblocking socket objects
Sockets can be either blocking or nonblocking, meaning operations such as connecting, receiving and sending either pause the program until they finish or do some work and return some status and continue on with the program. One way to handle nonblocking sockets in Python is by using the selectors module to sort socket objects into three lists depending on their current status and approach them that way. I thought asyncio uses nonblocking socket objects (from the socket module) under the hood in its own way
just asking
Are you talking about https://socket.io/ ? It communicates over web sockets which is confusingly named after BSD sockets
yeah its got two modules one is for client the other one is for host
(Web sockets is a protocol "upgrade" from HTTP)
i mean you make the backend with python and frontend with javascript
I think there's a more popular web socket package on PyPi
what bout the defualt installed one that is async.io
But this has little to do with conventional socket programming
ok i guessed
because it is for web stuff ?
There are examples of this in production
in socket.io
Well, Discord maintains an event gateway so its clients receive updates in real time using web sockets
The clients choose to subscribe to any event they want to be notified about
so as to not waste bandwidth I guess
What are you looking for exactly
They only use web sockets because Discord clients are web applications
They might have opted to using a custom application-layer protocol overall rather than WSS (secure web sockets) otherwise
What woud be the advantes of discord using this protocol over wss?
¯_(ツ)_/¯
Squeezing as much throughput as possible using the least bandwidth possible
Considering Discord clients are integrated into the web application, it makes no sense to do so as you will have to support new web standards as they come. My question is why they use web sockets over HTTP 2 or HTTP 3
After all you can upload files and whatnot
Crazy web stuff
It would be a pain for developers to write bots
WSS is already an established protocol and has many client libraries and tools out there
Httpx supports HTTP 2
And I don't know what WS control frames Discord's event gateway API uses
I wish discord.py would switch to using httpx
Well, and the event gateway API
to an HTTP 2 server
you can't await methods in socket.socket
they do, but you usually don't see it from the user's perspective since they're abstracted by callback-based transports/protocols, and also further abstracted into streams
see also source code: https://github.com/python/cpython/blob/v3.12.0/Lib/asyncio/base_events.py#L961-L962
Lib/asyncio/base_events.py lines 961 to 962
sock = socket.socket(family=family, type=type_, proto=proto)
sock.setblocking(False)```
Hey anyone can give me free sources like PDF which Theme is network and security using python?
Any idea why I cant connect sockets which are on the same router, im using eduroam's internet (unis wifi), however my network code doesn't work on my laptop and computer, however it works if I run the client and server on my laptop, or just my computer
since when have they changed this to networks?
people thought networking meant social networking
ikik
I suggested it on community meta but didn't realise they changed it
in the last 24 hours
someone help
probably some firewall's configured, test out some common ports such as 80, 443 or 22
I found that I could connect a socket from my phone to my computer because I was using ethernet for my computer however I couldn't connect to my laptop from my phone on the eduroam wireless network (it's shit)
a workaround to this might be to use a separate proxy server which both devices can connect too and communicate through
hello i have a error i don't get it "C:\Python311/Lib/site-packages\pydantic_core_init_.py", line 6, in <module>
from ._pydantic_core import (
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'
please help
wrong chanel
!ot pls not here
Please read our off-topic etiquette before participating in conversations.
hello everyone,
I am a new user of esp32 using micropython and in this field in general, I am facing a problem with sending data from the esp32 to a server using http request, Idk if it the best solution to use http requests to send a file, I have heard abut ftp, but I have no idea about it, and Idk what are the best protocols to use in this situation, I will be thankful for any help or guidance from you, and thanks in advance.
guys you got some good resources to learn networking and maybe some to automate network activities, services etc
no™️
learn by doing
emacs and micro > vim,neovim any day of the week
and im willing to throw hands on it
agreed, anyway go to #editors-ides or #ot0-psvm’s-eternal-disapproval, not here
why is DH1 required in X3DH?
Is this what you're asking about maybe? https://www.quora.com/How-do-you-ground-a-shielded-Ethernet-cable
"Xtal" is a masterpiece BTW 😉
Answer (1 of 9): How do you ground a shielded Ethernet cable?
Technically, there is no such thing as an “Ethernet cable”. There are many cables that can support Ethernet.
So, your question is unanswerable unless you tell us what type of cable you are using…
- Thicknet - 10base5 - 9.5mm coaxia...
ah thanks
and it truly is
so is the rest of the album
listen to geogaddi and music has the right to children
if u havent alr
Anyone knows of a short snippet or github repo that uses python for reverse proxying?
I want to connect to a couple of localhost webuis from remote connections without resorting to remote desktop solutions.
Saw your thread; my impression is that what you're asking for would be very annoying to implement from scratch. It'd probably be easiest to use a basic webserver like apache as a reverse proxy.
Good call, slightly used to XAMPP, so will look around to see if that can be used for it.
Thanks.
Hi guys,
I was rewriting my code, that uses pyodbc (with ms sql) to use that database remotly. Since i can't just add users to the database, i can only use it locally. I did succesfully translate my pyodbc code to send and recive SQL data using socket and pickle. But i get an error when pyodbc returns just one row:
TypeError: cannot create 'pyodbc.Row' instances
Any idea how i can solve it. I searched online, i was using pypyodbc before but pickle couldn't handle it well at all.
I did try converting it to a list using: resoult = list(cursor.fetchall()), and even tried using for loop to retranslate it to diffrent list but it still was giving me the same error.
can you send the full traceback?
I will as soon as I get home. So in 7hrs from now
hello,
I use software to analyze the spectrum. Is there a way to make it run for 5 seconds and then stop for 5 seconds like a while loop while retaining the settings? Do you think it's possible to do this with a script? or do you have any other Idea please
uset time.
Before looop initialize set StartTime to current time +5s when loop is looping check if current time is > StartTime if so start sleep(5s)
Traceback (most recent call last):
File "C:\Users\Michal\Documents\Python\client-server\UI\main.py", line 475, in Renamer
self.OCRMatch.multipleOCR(self.sql,self,settings, './frames/')
File "C:\Users\Michal\Documents\Python\client-server\UI\OCR.py", line 234, in multipleOCR
renameTo = sql.selectSQL(query)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Michal\Documents\Python\client-server\UI\mainSQL.py", line 63, in selectSQL
respond = send({"query":msg, "QueryType": queryType})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Michal\Documents\Python\client-server\UI\mainSQL.py", line 35, in send
return(recive())
^^^^^^^^
File "C:\Users\Michal\Documents\Python\client-server\UI\mainSQL.py", line 43, in recive
unpiclked = pickle.loads(msg)
^^^^^^^^^^^^^^^^^
TypeError: cannot create 'pyodbc.Row' instances
Hey friends I have built an ASGI python web framework if someone interested please check out here: https://pypi.org/project/aquilify/
oh I see
you should turn the rows into regular tuples before pickling them
it should just work as something like
rows = [tuple(row) for row in cursor.fetchall]
@blissful dawn
thanks for your response. if I understood your message correctly, I need to write a shell script?
you are on python dicsord, so i assumed you use python, time is one of the liblary
@blissful dawn
yes that's true, sorry if you find my question a little strange, I'm a beginner in IT, that's why I asked. Thanks for your help, I'll try it tomorrow and let you know if it works.
yeh it doesn't really works. I found yesterday or so when was dealing with pyodbc error altogether that there were problems with pickiling resoult so they plugged that hole. I assume it wasn't really checked before release, and since databases are rarely translated over TCP using custom software written on python, there were not many cases like mine
but i managed to make it work :
try:
self.cursor.execute(query)
self.rows = self.cursor.fetchall()
if not self.rows:
#print("No data found")
return None
else:
print("QUERY:",query)
print("Return lenght:",len(self.rows))
if len(rows) == 1:
self.cursor.execute(query)
self.rows = self.cursor.fetchone()
else:
return self.rows
except odbc.Error as ex:
print(f"Database error: {ex}")
So i just rerun query if it was just one resoult of it and gona fetch one, that seems to be working so far
posting for evryone intrested, tho i doubt that anyone gona use it 😛
Ye i know it is not pretty etc, im just a hobbyst, and if it works, it works
One time stand:
from datetime import datetime, timedelta
from time import sleep
def Run():
timeStop = datetime.now() #assign current time
timeStop = timeStop + timedelta(seconds=5)#assign add 5seconds to it
while timeStop > datetime.now(): #do some code as long as timeStop is bigger than current tiem
print("some code here")
sleep(0.5)#just for decoration, slowing down the printing
sleep(5)#sleep 5 seconds
Run()#repeat
if __name__ == "__main__":
Run()
Or it doesn't work after all... But now doesn't work in fewer cases, that's a progress I guess
@blissful dawn
oh thank you very much for your help
I am trying to build a network client that hides secret messages in the data section of an ICMP Echo packet, as well as a network server that captures the Echo packets and decrypts/prints the secret messages.
My server/listener seems to receive and correctly print the message sent from the client on my windows local machine but it does function on my linux virtual machine and I am not sure why. additionally, I can't see any of my traffic when i filter for icmp on wireshark
below is my code of the client:
hey i am looking for help from an expert in web scraping
anyone who can help dm me i will give you 25 usd
just ask your question
ICMP often needs special privileges. on linux, if I remember correctly, you need the CAP_NET_RAW capability. also, your firewall, or virtualization program may be filtering it out
i know kinda unrelated, but did anyone try pump.co to lower AWS costs? I'm wondering if it is literally free money or if there is a catch... like loss of some functionality? does anyone know?
anyone who had experience with aiohttp?
https://discord.com/channels/267624335836053506/1184484991162388502
Hello folks, would anyone have some good resources on implementing a vpn server and client, can be using sockets or through a protocol like openvpn. Or some book parts that explain the concepts 🙂
2. Follow the Discord Community Guidelines and Terms of Service.
!rules 9
Upwork and Fiverr exist for that
only exists.. not working
it works well if u want to be a borderline slave, making new google for budget of 50$
Hi i have a bunch of annotated images and i want to make a python ai model that trains with those images so that it can detect the image from a given picture
can someone show me a good course or where i can get started
neural network
please read the channel description
Discussion on network protocols, technologies, hardware with relation to Python
network, as in the internet
Is it possible to use my own personal cookies from my own browsing (in this case firefox) with requests/httpx?
Why not
yes
how then? I used an extension to extract the cookie of the site I want
but how do I load into python?
https://github.com/borisbabic/browser_cookie3 u can use this to get cookies for cetain domain
With requests: https://stackoverflow.com/questions/31554771/how-can-i-use-cookies-in-python-requests
Selenium works in a similar way
not what I meant
I meant, how do I load the file, the cookies.txt into the environment at runtime
not how I use it with requests
i dont understand the question
explain better
just read text file?
You'd have to translate to a dictionary as shown in the SE link / requests documentation.
This one spells it out further: https://stackoverflow.com/questions/14742899/using-cookies-txt-file-with-python-requests
hi
hi
hi
hi
hi
:incoming_envelope: :ok_hand: applied timeout to @wise leaf until <t:1702981637:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
:incoming_envelope: :ok_hand: applied timeout to @pulsar berry until <t:1702981640:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
lol
nah
nvm solved the problem
Why wouldn't it be? It's the default domain for commercial sites in the US, a large and high value market
Oh my bad I mean cheaper
Oh I see. The answer here seems reasonable: https://www.quora.com/Why-are-Namibia-na-ccTLDs-so-expensive
Answer (1 of 3): Namibia (.na) domains are the 2nd most expensive ccTLDs in the world at around $5,000 USD. Nigeria (.ng) domains the most expensive, at $40,000 USD.
Each ccTLD (country top level domain) has a manager, and it's the manager that sets the price of registration (and the registrars...
Yeah, one of my country is on that list
I suppose getting a .com would be more worthwhile then
ICANN was a mistake
i can ssh into a server with the credentials but when i try to use paramiko client.connect it is providing authentication failed
Any idea why?
It works for some servers but for some it doesnt
The credentials are same for multiple servers so some of the servers work and some dont. So the credentials shouldnt be invalid
Can I reserved a section of a home network? Like if I want to make IoT devices, can I have them pick an address from a specific range e.g xxx.xxx.x.700-xxx.xxx.x.749?
There are no valid IPs like that, but if you have a router that supports VLAN tagging, sure
Otherwise you can do one by one IP reservations where you assign each IP to each device manually
Maybe there are other options, but that's what I know of
Yeah it was just a random selection and I used x as a place holder since I’ve had both 192.168 and 192.68 local IPs. I’m wanting to make a plug and play home automation system and part of that would require auto set up of each module used. So when I plug up a 3rd device, it will select a free up address from the accepted range and update the local flask app for the user to use.
It's called a subnet and yes
Address allocation is handled by DHCP. You can see what configuration options your router's DHCP server supports, or host your own.
Could I have a main device that allocates those? Like a PC connected to my router that sets itself up upon connecting to a wifi?
More or less. But it may not be all that easy to set up depending on how comfortable you are with systems admin type things.
I’m willing to learn. Like I said, I want to make something plug and play where the main device handles all the configuration and the user just remakes it/configure their specifications e.g. time base automation.
yes, sounds like you want a dedicated dhcp server
these days home networks have dhcp built in to the routers, however
but most of the config can be done in router dhcp srevers
If I were to attempt this myself, I'd probably try it with pfsense on a VM since my primary router definitely isn't advanced enough. Looks like it can be tricky though. https://www.reddit.com/r/PFSENSE/comments/r77gdl/is_there_a_quick_guide_to_setting_up_a_vlan_for/
I would need a main device that host the flask app anyway so that seems like a great place to set this up lol.
can someone help to set up a minecraft sever?
seems its because the ports are closed but I dont know what to do
F
?
ISP issue, just give up
why?
its something with port fowarding if its a issue with the isp, i would like to at least check
if is that is true
The details of port forwarding depend on your router model but instructions are usually easy to find
the thing is that i know nothing about networking, so i dont know what is the issue
maybe that part is done correctly but but the ports are closed
or firewall :/
"Maybe"? I don't know what that means in this context. Did you or you didn't you? What port(s)?
If you're on Windows you can check the firewall at that level. If you're on a home network, you would know if you have a firewall at that level because you would have had to set it up
im gonna check
the port is 25565, I think I did the steps right, but im not sure can i send you a dm with the screenshots of my config?
https://portchecker.co/check-it and when I enter this website it says that port is closed
this is what I did, disabled the windows defender firewall, not sure if this is enough
this is just windows firewall, you also need to port forward on your router
Your computer isn't connected to the internet. Your computer is connected to your router, and your router is connected to the internet.
When your computer sends traffic to the internet, the router can easily forward reply traffic back to your computer.
But if random traffic from the internet comes in that wasn't preceded by an outgoing conection from your computer, there's no way for it to know which internal computer that should go to.
Unless you configure it to tell it to do that.
This is what port forwarding is
It tells the router which internal computer to send incoming connections to.
If you think you've done the forwarding step correctly, then you might want to check if you're on CGNAT, which is just another layer of NAT at your ISP
If you are on CGNAT, you are screwed.
You can find out by logging into your router and looking for its external IP address
(googling "my public IP" will NOT work. That will just show you the internet address of the CGNAT router)
If your router's external IP address is in any of these subnets, you are screwed:
192.168.0.0 - 192.168.255.255
10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
100.64.0.0 - 100.17.255.255
CloudFlare tunnels can help you access the resources even if you are behind CGNAT
how would you explain Network Stack?
That could refer to any set of networking technologies that are used together. Depending on the context you might be talking about the OSI model or something else
yeah I forgot why I asked that but I think its about the virtual networks. where it goes into layers to get send/recv but thanks for trying to help
it was in those subnets, thanks either way
Hey, how do I encrypt my intial message? I have written a server that functions as cloud. The uploading and downloading of files works just fine. I have even added password authentification and fernet encryption for the file transfer. I made it so that the server can handle multiple clients at a time, so that I can access it with multiple decives at a time. To ensure that every client has a secure connection, the client sends with the password my fernet key which is to be used for the file transfer. Obviously when you intercept the intial "handshake" between the server and the client you'd be able to read the password assigned to the specific client as well as the session encryption key, making all my security useless...how can encrypt the initial handshake when the server doesnt know the key before hand
Hello, are you using the same fernet key for each of your clients ?
um so
have you tried tls
TLS is a protocol that's used to negotiate encrypted connections between clients
Transport Layer Security (TLS) is a cryptographic protocol designed to provide communications security over a computer network. The protocol is widely used in applications such as email, instant messaging, and voice over IP, but its use in securing HTTPS remains the most publicly visible.
The TLS protocol aims primarily to provide security, incl...
python has an implementation called ssl
!d ssl
Source code: Lib/ssl.py
This module provides access to Transport Layer Security (often known as “Secure Sockets Layer”) encryption and peer authentication facilities for network sockets, both client-side and server-side. This module uses the OpenSSL library. It is available on all modern Unix systems, Windows, macOS, and probably additional platforms, as long as OpenSSL is installed on that platform.
Note
Some behavior may be platform dependent, since calls are made to the operating system socket APIs. The installed version of OpenSSL may also cause variations in behavior. For example, TLSv1.3 comes with OpenSSL version 1.1.1.
@mild tusk what are you using to ccommunicate with your clients? ssl or http?
Neither. I'm using TCP. Im using fernet for my encryption but the moment I go online(therefore stop using my localhost) i get the errorpy Exception has occurred: InvalidToken exception: no description File "/Users/juliuskorbjuhn/Documents/Programmierung/Python/Projekte/projectFolder/networking/logic/clientSide.py", line 23, in _decryptData return self.cipher.decrypt(base64.b64decode(data)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/juliuskorbjuhn/Documents/Programmierung/Python/Projekte/projectFolder/networking/logic/clientSide.py", line 45, in _download dataChunck = self._decryptData(self._recieveHeader()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/juliuskorbjuhn/Documents/Programmierung/Python/Projekte/projectFolder/networking/logic/clientSide.py", line 65, in main self._download(filePath) File "/Users/juliuskorbjuhn/Documents/Programmierung/Python/Projekte/projectFolder/networking/client.py", line 5, in <module> client.main() cryptography.fernet.InvalidToken:
I checked everything. Implemented meassures to check if hashed key is the same and thereby verifiying key integritiy(and the key is transmitted correctly). So i really dont know what leads to this error https://paste.pythondiscord.com/KGYQ
Hey im looking to create a home network
has anyone faced any issues with the above router
?
oops wrong one
This is a Python server. The odds that someone here has experience with some specific router is pretty slim.
True but I'm willing to hedge my bets :p
anyways I'm pretty new to networks
should i just invest in a router for now? and look into other network devices once i gain more knowledge
is that dracula as your pfp?
Sure, you can do whatever you want. We can't recommend what you should buy if we don't know what you're trying to accomplish
Ah my bad let me provide some context ^_^
You're making fun of my face wtf?
0-0 i mean dracula is quite a handsome bloke
so i'd take it more as a compliment
anyways for context I'm trying to cover >1000 sqt of living space with adequate high speed wifi network coverage
I want to be able to stream HD content on multiple devices anywhere within the 1000 sqft
I would think any modern router is fine for that. A lot depends on walls, interference etc
win is a win
👍
hi,
so what you're doing right now is a password-authenticated online file storage system right?
what i suggest you do is negotiate a TLS connection and then do the password authentication through the encrypted tunnel (which is easier and safer, and can be done in stdlib :))
i have some code which connects to a websocket, sends a ping, waits for a pong and calculates the time it took to receive a response, instead of regular "ping ip" thing, is there a way i can use that instead of regular pinging to find the VPS/hosting provider that i need?
Is your choice dependent on the location of the VPS ? why would ping ip not be suitable
You asked this only a minute before you asked the same thing in #web-development . Please don't do that
because i've found VPS's which by pinging give me 1ms, but with websockets give me 9ms, and also VPS's which by pinging give me 0.1ms, but with websockets give me 50ms, websocket latency is more important to me in this case
sorry, i thought it met both criterias and wanted a faster response, wont happen again
pinging or traceroute just isnt cutting it for me, i'm just burning money by testing each VPS individually, putting my code in, testing the websocket latency because as far as i know theres no other way to connect to a websocket and test its ping pong latency in bulk
Ah, in that case you're right. How are you testing the latency, are you using concurrent connections or one connection ? not sure if your goal is to automate this or what exactly, but if connecting to the websocket is what you'll be doing eventually in your app then it is a more reliable metric than ping, if you plan to host an api however then you need something different
i connect to the websocket, send connection init message, and then i send ping and measure the time it takes to get a pong back from the websocket if that makes sense, i buy a vps, install dependencies, run my code and test the latency, im tired of burning money and wonder if there is a way to do this in bulk, similar to how regular 'ping a site' checkers work but with websockets
Well ping operates at layer 3 of the osi model so that is why you can basically ping any site/ip since it is supported by default on most systems (except if disabled), websockets however operate at layer 7 so you need to run something that accepts a websocket connection, automating this process of installing/running is definitely possible but requires more effort and tool knowledge so what you're doing is probably the quicker way
is there any way i can speed up this process or make it more efficient? it would take me ages and hundreds if not thousands of dollars to find the vps with the lowest latency
Yes there is, is your app already dockerized ?
no i mean not in a coding way, can we take it to DMs?
Yeah sure
hi guys i wanna make a game in pygame, but i need to know what protocol should i use for tha lan multiplayer ?
tcp
tcp is just a low-level protocol to transfer data
you can transfer basically anything
Ok thx
guys how do i enter into e.loadinternal through python ? using requests module if possible
what do you mean 'enter'?
how can i make an .py file to an app or does that not work
Wrong channel but do you mean that you want to compile a windows exe? There are a few tools for that you can find
Is there any way to control whether a script will route through a vpn or not?
im looking for a networking expert who can find the best hosting provider with the lowest latency to a certain websocket protected by cloudflare
#rules 6 9
Generally not but depends on... everything. What sort of script, what VPN, etc.
rules 6 9 lool
Well apparently its called split tunneling and its way easier on linux than windows beceause linux lets you use namespaces
surfshark lets you do split tunneling through their gui, but they dont have a CLI to use
anyone familiar with self supervised learning here?
Lol that is an ml topic
Not literally about learning
You should ask your actual question over in #data-science-and-ml
That would depend on the VPN protocol used, It is possible to do it using proxies however
I have both wireguard and openvpn
Well openvpn has a cli you can use to connect, you can call it from within the script or outside
So does wireguard, and I've made scripts to do that using wireguard, but I want one script to use a vpn while another script doesn't, while both are running at the same time
I see, and are you using requests or what other libraries that do network calls in your script
It uses the socket library
I actually usually run a system-wide vpn, and I'd want the script in question to be excluded from that, rather than use a specific tunnel or something
Alright, then I would suggest maybe to find ways to make the script route through another network interface (i think dbus-python allows that), and add a routing rule/network interface to your router directly or something
My landlord controls my router lol
well you can still do that
?
Self supervised learning is a machine learning topic
is it?
Yeah the pedagogy link was funny
Hello, I am getting a n interesting error:
BadHttpMessage: 400, message:
Expected HTTP/:
b'[]'
^
File "aiohttp/client_reqrep.py", line 899, in start
message, payload = await protocol.read() # type: ignore[union-attr]
File "aiohttp/streams.py", line 616, in read
await self._waiter
File "aiohttp/client_proto.py", line 213, in data_received
messages, upgraded, tail = self._parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
when calling a 3rd party endpoint (HTTP GET) from a kubernetes pod. Surprisingly, the request works without trouble when running locally with hte same code. What are the suspects here then? OpenSSL versions?
I also tried a simple curl from the pod via shell and that works as expected.
Hey, can someone recommend a telnet library? The most popular one seems to become deprecated soon as newer python versions are comming out
why telnet
go use ssh
Assume that telnet is a requirement
go migrate to ssh
This one was last updated in June
November
Looks like there’s a few that’re still getting updates
but why
are you watching star wars in your terminal with python? 😭
No
I just do that in Bash
No Python required
thats basically the only reason for telnet
I should make that available over SSH
Get a networking job
Tons of dedicated networking hardware wants a serial cable or telnet
Those routers would look at you like a crazy person if your brought SSH in there
why
✨ legacy ✨
✨ ssh is older than WPA ✨
WiFi doesn’t have anything to do with SSH
I finally did it after 13 hours of continuous coding
AAAA
Who's into blocking malicious packets?
Took me 13 hours to be able to create a tool that blocks botnets 😆
Uplink and firewall doe
✨ still tho stop using telnet in 2023 ✨
users: oi why did i get blocked
Who knows how to implement multiplayer (online)
not very descriptive
there are multiple ways
UDP, TCP, HTTP (if you're a lazy di-), and it really depends on your usecases
TCP,
@exotic condor
Hers an example
Kind of bad , but..
The server can create a client task (when a user joins), and the client can create a command task (on command use)
The reason I did this is because it allows for more complex behavior like server events and more. Since certain commands may require waiting on something, the command needs to be a task.
# V.1
@Commands.command("input-test", 3, show_usage=True, description='Enter a number for testing.')
async def input_test(client:Client):
message = Message(sender="Server", message="Please enter a number below", main_type=MessageType.CHAT, sub_type=MessageSubType.COMMAND_RESPONSE)
await send(client, message, to_channel=True)
event = Event('user', client.id) # user, channel, and server events
message_output = await event.request()
await send(client, message_output) # Send to user
try:
message = Message(sender="Server", message=f"You have entered the number : {int(message_output.message)}", main_type=MessageType.CHAT, sub_type=MessageSubType.COMMAND_RESPONSE)
except ValueError:
message = Message(sender="Server", message=f"Must be ant int", main_type=MessageType.CHAT, sub_type=MessageSubType.COMMAND_RESPONSE)
await send(client, message)
``` Weird syntax and boiler plate code rn, but this a a custom command someone *could* make.
Im going to sleep. no idea if this is good, or terrible design choice. Too late now I suppose, since I have like..1200 lines of this
probably more of a #async-and-concurrency thing..
Sorry, I rarely see pings for some reason. I just happened to see this as I was looking through the channel list.
all good.
What do you think abt this? Not sure if you're still.up
The only issue I see is each user using a command. Which means 2 tasks per client. Not sure how performance impacting that is. Works with 100+ clients rn
and you could of setup pfs on an old box in 5 min
im looking for "computer network" course, tutorial etc. for my school exam
it could be on udemy, i guess there are on sales today
any idea ?
Maybe look at Network+ study materials, especially books, but if you want free videos then Professor Messer on YouTube is great
https://youtube.com/playlist?list=PLG49S3nxzAnlCJiCrOYuRYb6cne864a7G&si=ZWKnGz0_SFlV_jc1
https://youtube.com/playlist?list=PLG49S3nxzAnmpdmX7RoTOyuNJQAb-r-gd&si=V6bSbE1_6R2cJrvr
what are the differences
The first one is more up to date, so probably what you want
Thanks
Does anyone know how to check if the client or server has dropped the connection in socketIO?
Never really have worked with oauth and want to set up an app to login to user's facebook business account and get page access tokens. Any ideas of how it might work if anyone here has worked with the Facebook Graph API or sdk? also id most likely be using the facebook-sdk library
just ask
what do you need help with?
how can i find the exact hosting provider of a websocket? i'm connecting to their websocket, my latency is 7ms but its still too high and someone has a better one, there are no docs for the site or anything else, im desperate for help at this point, i tried many different hosting providers and a lot of different locations
the websocket uses cloudflare, perhaps if someone can make/has a tool similar to pinging ip addresses from different datacenters, but for websockets that would be extremely helpful, ive been trying to figure this out for a month now
i have a rough idea of where the websocket server is, that's why i have 7ms, but i can't figure out a better location because i assume it must be using a non standard hosting provider
its too high because someone else found 1-4ms, but they wont tell me
are u using a server??
rent a better server 💯
try other lang than py also
already running a dedicated instance rather than a regular shared VPS
using both nodejs and python
i need help finding the specific provider with the specific location
try with shodan
no results found
i was arguing with people over on reddit about 0.1ms of computation
yeah but network-wise
7ms is decent
and it is not like you can optimize the server
or the cables until the target
:p
i mean 0.1ms is 70x less than that
one's directly connected by the chipset and the other one is km away
well guys 7 ms would be more than enough for me, however i am getting absolutely wrecked by other people with 2-4 ms, that's why i need this help
have you thought of the idea
that they might be closer to their vpses
i get 1ms latency from my srver!!!!!! (its an rpi on my local netwokr)
did you read my message? i need someone to help me with the exact hosting provider that is less than 6-7ms
i've already tried vultr, digitalocean, azure, google cloud, aws, contabo and a few more
all locations, i assume it's somewhere in france but not standard like paris or marseille that mainstream hosting providers use
maybe someone has a traceroute script like they do with ipv4 for different datacenters, but for websocket use instead or any tool similar to this
I also get 1ms latency for my server
how surprising
btw what do you need the server for @tribal dome?
to run my trading bot
game skins trading
hey guys, does anyone have experience with setting up a connection via wpa with a new raspberrypi 4
You should just ask your actual question
I have not worked with networking at all and have just been learning the past couple of days. I am currently attempting to connect a raspberry pi 4 to my laptop headlessly via my router. I can ping the raspberry pi without any lost packets and verified port 22 is open and listening. I also includes a blank ssh file on the pi's SD card and a wpa_supplicant file with the correct network name and password. Using Windows PowerShell, i have tried ssh -1 [variety of usernames and passwords for the raspberrpi] but am receiving either 'connect to host * port 22: Connect refused' or 'protocol v.1 is no longer supported'. I have tried researching online the past couple of days to see what I am missing/where i am making a mistake, and either can't find a solution or don't understand the technicalities. Just trying a different avenue to seek help.
Hi there, I've been playing around with Wireguard for two reasons, having my own VPN for forwarding all public traffic, and for security. Someone has mentioned that a prerequisite to connecting to one of their VPS' requires connecting to the VPN first, which I would like to consider replicating.
However, I'd like some second opinions on if this is worth doing. Currently I just use SSH keys to SSH into my VPS.
There's nothing wrong with simply using SSH if that's working for you. It's secure assuming you're using it securely. A lot depends on all the details of what you're doing.
SSH with password-based authentication disabled, some anti brute-force mechanism on the host like fail2ban, and automated upgrades together are pretty strong
I suck at networking. I'm behind a vpn, there's some IoT devices I can see on the vpn network, they are supposed to answer to UDP request, but they don't (or I don't see it on wireshark). I think it's because those devices and my machine aren't not on the same sub network. Could anyone help me ?
What do you mean "behind a VPN"? Are you on the same gateway as the IoT devices and is it one you control (e.g. your personal router)?
Hello guys im trying to learn requests library can you suggest me a channel or course?
I mean I'm using a VPN to access the devices.
Someone explained to me as I don't control the VPN and as the router on the other side is blocking/filtering queries, I can't do what I want through that VPN.
Correct
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
If they're blocking the traffic it's likely on purpose, helping with that would be against the rules here
what exactly is this rpc stuff?
A protocol for executing a function call with parameters over a network
Remote Procedure Call
k ty
ee can we chat on dm?
i connect to a graphql websocket, but when i send a mutation even with 6ms latency i am only given a response after 100-2000ms, which makes me late because someone else figured something faster out, if anyone has any ideas or non-standard practices that can be used to speed this up please let me know 😄
u have been asking this for a while but never said which endpoint
adn what messages
I've already made a thread in #1198283690862710794 with more information
there is no endpoint
I am trying to implement my own tls client with http/2 and a open connecting.
import socket
import ssl
from hpack import Decoder
host = 'www.example.com'
port = 443
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
context = ssl.create_default_context()
context.set_alpn_protocols(["h2"])
wrapped_socket = context.wrap_socket(sock, server_hostname=host)
wrapped_socket.connect((host, port))
x()
...
def x():
req_raw = build_raw_http_request(
method="GET",
url="https://example.com",
headers=headers,
query=params
) # returns raw http data
print(req_raw) # ->GET https://example.com HTTP/2...
wrapped_socket.send(req_raw.encode())
response = b""
while True:
part = wrapped_socket.recv(4096)
response += part
if len(part) < 4096:
break
""" response is like "\x00\x00\x12\x04\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00d\x00\x04\x00\x01\x00\x00\x00\x05\x00\xff\xff\xff\x00\x00\x04\x08\x00\x00\x00\x00\x00\x7f\xff\x00\x00" which I think is binary for the response payload, settings etc
"""
decoded_headers = decoder.decode(response) #-> hpack.exceptions.HPACKDecodingError: Unable to decode HPACK integer representation from <memory at 0x0000020DF3D14E80>
print(decoded_headers)
Am I understanding it wrong?
which message are u sending, or which part of the page contains those messags
subscribing to onCreateTrade, sending joinTrades queries
hey i am begginer on flask.... i follow tuttorial and i run into this error. basicly i have to import my db but its keep saying that module dont found.. can anyone help me and thank a lot
yo im quickly trying to make a flask website but for some reason, the website returns nothing when i access it
check pip list to see if flaskblog is present and make sure you are using the correct virtual environment if you are using one.
We don't know the details of whatever tutorial you're following so we can only guess.
I assume flaskblog is the project you're building, in which case the problem is that you're inside its directory and need to start Python from ~/ instead.
Hi guys, trying to create an upstairs network but there’s no Ethernet through the house…
My solution is to install a Wi-Fi extender as a “slave” in the top floor and feed that into my upstairs router via Ethernet, which then serves my server and other kit…. what extender would be best to use for this, in terms of Ethernet throughput? I get great Wi-Fi speeds, even to my old extender but the Ethernet port is very slow
u can try powerline adapters
use electric wires to get internet upstairs
I don’t think that’s how it works
Also aren’t they incredibly slow?
thats exactly how it works
I think even a coaxial converter would be faster? 2.5Gbps maybe?
if u have u can try that also
i need help 😦 so basically i am making a school project
i have an Ip address endpoint when i put it on my browser i get correct ip address of mine but when i use the endpoint through my fastapi which is hosted on deta space i get incorrect ip how can i fix this issue?
can you re-explain
basically my project is when someone open my endpoint i get their ip address
iam using https://docs.abstractapi.com/ip-geolocation basically it gives a url and your api key and when i copy that and i put on my safari tab i get my correct ip address
but when i use the same api inside my fastapi which is being host on Deta space i get the wrong ip address
It's the right IP address. IP addresses are just more complicated than you think I think.
If your request is going through any kind of internet gateway then you'll see the address of the gateway.
The IP address that this server tells you is whatever address it needs to reply to to send you the response.
anyways if you're using deta, surely you can just your instance's public IP address from them directly.
That's much more straightforward and reliable than some third party
And if you want the extra data like country, postal etc. you can still use the API.
Just provide the IP address directly in the request. It's an optional parameter you can submit.
I suspect that there may be a public IP address that goes to your deta instance, but connections out don't come from that that IP address.
Can you give more information about exactly what you're doing and what about the IP address you're retrieving makes it "wrong"?
It'd be a lot easier to actually diagnose that way
Hold the phone, by "wrong" IP address do you mean when you send a request to your application from the browser, your application responds with the geolocation for your Deta instance?
I guess yes
Because I am in Pakistan
And I get ip for somewhere in India
I am guessing it’s returing ip for their data center?
Yes
The code is running in their data center, so the request is coming from their data center
This is an easy fix.
All you need to do is access the client IP in your code running on deta
Really? Easy fix? I spent last 7 hours working on it and after seeing I can’t access the real ip I felt like crying
I already went to that docs
It talks about cloud flare and I know nothing about it
😦
So sigh now I feel so demotivated and upset because I worked so hard
I even used the X-Real-Ip header
And X-forwarded header
But none returned the correct ip
I can not express how badly I need help with this
Ok, I think these docs actually might not even be relevant. If your instance isn't behind cloudflare then I don't think you need to do much special.
Can you get logs from deta, like if you print() some stuff out in Python can you retrieve that?
Yeah I can
what framework are you using, fastapi? flask?
Fastapi
are you using nginx or anything else on top of it?
https://fastapi.tiangolo.com/advanced/using-request-directly/
Ok, so in your request handler, you need a parameter for the actual Request object like shown here.
Great
request.client.host isn't giving it to you?
No it isn’t 😭
What is it giving you?
So there is a reverse proxy of some sort. Maybe they have cloudflare on all Deta endpoints
what's the datacenter IP?
- Something something
that's not enough, I need the whole thing
Rest assured if I wanted to attack some random data center I wouldn't need you to tell me its IP to find it
I want to check if it's in cloudflare's published IP ranges
Ok just a moment
Btw it’s 2:33 am at my place and I’m reopening my laptop just for you. Please help me solve this issue Katy or my whole 7-8 hours will go to waste
Also, just to see, add this to your function and tell me if the IP address you're looking for is anywhere in these headers
print(f"XFF: {request.headers.get('x-forwarded-for')}")
print(f"XRI: {request.headers.get('x-real-ip')}")
this is my current code ^
no :/
and its all wrong
Hmm so there is no XFF, and there is XRI from Amazon EC2... wtf
what can i do now? : (
Just in case there is something wonky with fastAPI's Header class, can you try getting the headers directly from request with this code?
can you give the exact code you want me to test
@app.get("/mo")
async def read_root2(request: Request):
v = f"Host: {request.client.host}\r\nXFF: {request.headers.get('x-forwarded-for')}}\r\nXRI: {request.headers.get('x-real-ip')}\r\nCCI: {request.headers.get('cf-connecting-ip')}"
return v```
katy is it okay if i can write you in private and share outputs there? : /
sure
i sent you the response
i lerning the programe and use python lang
If I use proxies, can I interact with the site and for example order things with my account?
in general, yes
hi peps!
I saw the following code on stackoverflow that is supposed to continuously check if the connexion is up and I'm wondering if that would inevitably lead to a stack overflow because if the connexion never breaks the function will never return?
import requests,time
def check():
try:
requests.get('https://www.google.com/').status_code
print('online')
time.sleep(5)
check_again()
except:
print('offline')
time.sleep(5)
def check_again():
try:
requests.get('https://www.google.com/').status_code
print('online')
time.sleep(5)
check()
except:
print('offline')
time.sleep(5)
check()
check()
Lol, there are multiple problems here but that's not one that I see
I wouldn't cross reference identical functions like that because it's unnecessary duplication
Except without specifying the type of error is almost always a bad idea too
you can write a cron job that schedules check() every 5 minutes
Hello guys i am trying to connect to my socketio server from python. But there is a problem. The problem is my server need accesstoken to connect but on python when i try to connect without accesstoken it still says it connected but i still cant receive any data. can anybody help me with this?
`import socketio
import time
global accessToken
import requests
import json
server_url = "ws://localhost:2099/api/admin/face-search/consume?companyId=1"
accessToken="xxxxxxxx"
sio = socketio.Client()
@sio.event
def connect():
global accessToken
print("Connected")
@sio.event
def disconnect():
print("Disconnected.")
@sio.on('face_search_request')
def on_message(data):
print(data)
sio.connect(server_url, headers={'x-access-token': accessToken})
sio.wait()`
tf is this code bro
just use while loop
or smth
is anyone able to help me with assigning an IP to a pico W server?
got locked due to timeout but the code is there
hello guys. iam learning networking but i dont know if it is the time to learn python with it or till i finish networking ??,i need advice ?
how do I handle sending receiving data on a single separate thread ? (main thread gui, second thread networking)
It's basically a question of what you want to build or achieve, plus your learning style. Do whatever keeps you engaged in learning and doing, that's all that really matters
I don't personally have experience with that but I would think any basic tutorial on threading should get you there. https://realpython.com/intro-to-python-threading/
its not a threading question
its about sockets
receive is a blocking function
how would I receive and send from the same thread
I could use a timeout say try receive for 1 sec then clear send queue then receive for 1 sec etc
but I dont like this solution
You should be able to handle networking and gui from the same thread eg asyncqt or qtrio
there is an inbuilt module called select which allows you to handle this situation. this module is quite low level however so its reccomended to use the selectors module (also inbuilt). alternatively you could use asyncio or suchlike if it's compatible with your project
import requests,time
def check():
try:
requests.get('https://www.google.com/').status_code
print('online')
time.sleep(5)
check()
except:
print('offline')
time.sleep(5)
check()
about the unecessary duplicate, I guess this works just the same doesn't it?
how come that doesn't fatally lead to a stack overflow after X amount of time if except: never gets triggered?
what type of error should also be specified and what could happen if none is specified?
sorry for asking so much questions I'm so curious 😁
You might be right about the stack overflow here... Just use a while loop outside the function instead
I don't know off the top of my head what errors you might want to handle, you'd have to try it without the exception
Or look through the documented errors request can throw and decide which ones you want to catch
use asyncio
Hi, is this a good channel for questions about gRPC? Mostly general questions, for example:
I'm working on a project which already uses grpc for communicating between multiple running python processes. This means that every time we add a message type, we need to add a new service for that message to the proto file, and write a client class and a service class.
It ends up being fairly spammy, with lots of boilerplate code. I'm wondering if there's a better way to do this (other than, of course, "stop using gRPC for that", which if I had my druthers...).
I am having a little trouble with raw sockets
I did s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.hton(0x0800))
but that last argument always drops OSError: [WinError 10022] An invalid argument was supplied
I tried replacing it with socket.getprotobyname("tcp") and socket.IPPROTO_TCP, but still the same error...
Anyone knows why?
I am basically just writing the bytes manually
like ```py
buf = b""
buf += b"\x01\x02\x03\x04"
...
I am writing ip headers and tcp headers manually
I found that the something always appends 8 bytes in the beggining of the packet.
bytearray(b' {"a": 54, "r": 54} ')
b' {"msg": "HelloAck", "type": "str", "version": '
1st packet is the header data which is always 128 bytes maximum however in this case an extra 8 bytes got appended in the beginning. The message is still accepted since the json is still parsable*
the 2nd packet now becomes broken as the client expects 54 bytes incoming but 63 bytes was sent in total.
I tried running it on a different server but it would just be fine.
bytearray(b' {"a": 54, "r": 54}' ')
b'{"msg": "HelloAck", "type": "str", "version": "0.1.0"}'
Which is an expected response
I am not sure what is the specific cause of this but these are ran on a VPS under NAT so not sure if it helps.
If anyone knows please enlighten me.
is there a faster way to interact with a graphql endpoint other than websockets
i connect to a graphql websocket, but when i send a mutation even with 6ms latency i am only given a response after 100-2000ms, which makes me late because someone else figured something faster out, if anyone has any ideas or non-standard practices that can be used to speed this up please let me know 😄
hello
which network proxy lib do u suggest to use
i want to make port forwarding proxy
PySocks -- You can't work with HTTP Proxies (obviously) but the codebase is simple and all connections will be routed through a socket
Hi, I'm having some trouble after enforce CSRF in a Flask Application. I use a decorator that check either if there is a Bearer token or CSRF token, this works fine, however when I try to do a POST call using postman for example I get 400 complaining about missing CSRF token
i was wondering if anybody had any idea on how to do this:
theres a website called brainly with essentially all the answers to this stupid course im taking for school (health)
it gets annoying having to manually look up the questionson brainly clearing cookies etc
i was wondering if it would be possible to make some sort of script or maybe something where i would input the question, it would find the top question ( brainly is where people ask questions and others answer) and then it would display the top answer to the question
i have experience with development but not a lot of networking, i dont know if this is possible but it seems like it is
if i finish all the health assignments i get to do other coding stuff for robotics which i actually enjoy
but first i have to finish health unit
feel free to ping
!rules 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
question, what rule does this break
or moreso how it breaks the rules
They have a rule against web scraping
using selenium gives low bot score than using http requests module yes?
Guys I am confused about public key cryptography.
Public key is used for encrypting messages. But I am unsure about the private key.
Some articles claim that private key is also used for encryption, whereas others say its only used for signing the hash of a message which is the appended to the original message to verify that the message has not been tampered with.
So if its only used for signing, then whats the point if the data is still visible to 3rd party? I have heard that in tls, it uses the public key to decide on a session key for symmetric encryption, but I am not sure how that works.
Either can be used for encrypting data to be decrypted by the other. Whick key you encrypt with depends entirely on what the purpose of the encryption is.
And the point of signing is the signature
You don't sign a contract to keep the contract a secret. You sign it to prove that you authorized it.
The point of signing is in fact that the data is not secret.
This is how website certificates work
When you connect to google.com, their server sends you a document containing a public key.
This document is signed by a certificate authority
Using the cert authority keys which are already installed on your computer, your browser can validate the signature of Google's certificate in order to determine that it is legitimately from Google
And then your browser can use Google's public key to validate data signed by Google.
ok so
asymmetric encryption (in tls) is mostly used for 2 things
1: getting a symmetric key
2: ensuring authenticity
so, what it does is that both sides send a public key that is used to derive a shared symmetric key (key exchange)
the public key needs to be signed by a signing algorithm to ensure that it is sent by the first party (signature)
@hasty quest gave a more in-depth explanation
So the SIGNED data is not secured (Can be read by others)?
I am trying to create an application using sockets (that uses self signed certificate generated on the server side). The certificate should be stored in a pfx file with the private key, and then a cert file will be distributed along with the client application.
The key exchange happens when you receive the certificate from the server
the client send the key to the server?
or something like that, during a tls handshake
There is a TLS handshake. It's complicated, you'll need to read the RFC to do it by hand
alright
Also I am confused about this. I have heard there are two types of certificates. Server side one and one for the client side.
Should the Server authenticate to the client, or the client authenticate to the server?
you can transfer public keys fine
public keys and signed data isnt secret
the server authenticates itself to the client
oh that makes things clear
In what case should a client authenticate to the server?
i mean
the only time in which a client needs to authenticate itself to the server
is when the server wants to ensure that the client is a certain person
Oh
which can already be done through passwords
Alright
or logins
The same certificate can be used for tls and other encryption? Or is it that tls has a particular certificate
i mean you could be able to use it for other things
oh
but like
Is this okay? I am pretty new to networking
why
As far as I know, .cer file does not contain private key
maybe?
Guys anyone here with a deep understanding of web scraping?
I am trying to retrieve a script through a httpx response.
my code -> send code to server through a POST -> server sends code to engine -> engine runs -> engine returns result to server -> server returns result to me
I want to scrape the engine code through the response.
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
Before you flag and accuse, read the question first.
Has anyone had issues with FastAPI/Gunicorn servers refusing connections?
I was running a service handling ~3 QPS (on a single 4 core box) behind a network load balancer on aws from 3 clients I control in the same region (different AZs) and I've run into timeouts / ServerDisconnected exceptions when connecting to it on the client. Also seeing Target_RST_Count and NLB_RST_Count in my cloudwatch logs fron the NLB.
I think going from a single Uvicorn server to a Gunicorn server with 4 workers has improved the situation (only 2 failures overnight vs like typically 200 before), but I am honestly somewhat surprised I am getting any dropped connections for traffic inside AWS.
I think I'm probably going to make the service API idempotent (it is stateful) and add retries, but I feel like this shouldn't be happening? But maybe I have unreasonable expectations, I have not previously been responsible for this sort of thing.
Anyway, curious if anyone has similar experiences.
Hello I'm kind of new at this. Doing threaded sockets and I can get some communication but then it stops. Can't figure out why that is.
10.244.0.0/24 dev kube-bridge proto kernel scope link src 10.244.0.1
so the above route has no gateway specified. so all it does is specify what interface to use and what source to log for the next package hop directly to the destination, correct?
Dropped connections can happen for a wide variety of reasons, it's hard for us to pinpoint exactly what it is from just that.
But also - I think it might be tough to make a stateful API idempotent
anyone knows what this might mean
websocket: bad handshake: HTTP 404
in a VPNs log ? uhm im not good at this but i think im using a VPS to try to connect to a certain website that i put in the config so that means it cant reach it i guess?
What do you consider small, medium, large, and enterprise networks based on the number of devices served?
It's totally arbitrary. Small could be under 10, under 100 or under 1000 depending on your perspective
hey , How can i make an easy HTTPS request?
The simplest option is using a library like httpx, aiohttp, or requests. What is your usecase?
404 Indicates the wherever you were visiting doesn't exist
well it turned out the answer to this was that gunicorn's default keep-alive timeout is 2s, which is too short for the clients I had; I bumped it to 65s and switched to an ALB (probably unnecessary) and my connection failures went away.
uhmm well if i open that website it works for me fine so it does exist
can i speak to you in dms?
Access points are the only sort of thing that bridge wifi connections to ethernet/wired connections, correct? There are no other such things in charge of turning wifi connections into ethernet of vice-versa, correct?
yes. Though nowadays routers have this built in without a need for a dedicated WAP
Hi, anyone good at networking? My laptop can't seem to access any DNS records from my DC running on an ESXI server... DNS seems to be working as all other VMs can use DNS fine, I have tried flushing DNS etc and yes I have set my DNS server lol
It works fine when I SSH into ESXI from a console but doesn't work from my machine?
There is connectivity between your laptop and the DC?
Yes I can ping it etc
I can ping all VMs on the ESXI
anyone good in virtualbox ?
Hi, i'm pretty new working with sockets in Python. I'm implementing an example of file uploading from a client to a server, but it doesn't work. The algorithm i'm following is the following: The client reads 4096 bytes of a file opened in 'rb' mode, then it encrypts the data readed and sends the data to the server. If the EOF is reached (I checked the EOF as if there's no more data in the variable that holds the data), the reading loop breaks.
The code for upload a file is:
def upload_resource(file_path: str) -> None:
try:
with open(file_path, 'rb') as file:
while True:
byte_data = file.read(4096)
print(byte_data)
if not byte_data:
encrypted_end_tag = encrypt(key, b"<END>")
client.sendall(encrypted_end_tag)
break
encrypted_byte_data = encrypt(key, byte_data)
print(encrypted_byte_data)
client.sendall(encrypted_byte_data)
except FileNotFoundError as e:
raise_error("Error when opening the file", e)
except Exception as e:
raise_error("Error when sending the file", e)
On the other hand, the algorithm I followed to receive and write the file uploaded is the following: Using a context manager, the script opens a file in 'wb' mode. With an infinite loop, the script receives a chunk of 4096 bytes, decrypts the data received and appends it to a variable called byte_file, that holds the received data. Is the end tag (b"<END>") is reached, the infinite loop breaks and the data held in byte_file is write into the file opened before.
The code of the server is:
def receive_resource(file_path: str) -> None:
file_name = pathlib.Path(file_path).name
download_directory = pathlib.Path('./downloaded_files/')
if not download_directory.exists:
os.mkdir(download_directory)
saving_path = pathlib.Path(str(download_directory) + file_name)
with open(saving_path, 'wb') as file:
byte_file = b""
while True:
encrypted_byte_data = target.recv(4069)
byte_data = decrypt(key, encrypted_byte_data)
if byte_data == b"<END>":
break
byte_file += byte_data
file.write(byte_file)
The thing is that every time I run both scripts, basically the program gets stuck and there's no data wrote in the file. What I'm doing wrong?
If it matters, the decrypt and encrypt functions are:
def decrypt(key: bytes, data: bytes) -> bytes:
"""
Given a key and a data stream, this function decrypts the data inside the data stream.
Parameters:
- key (bytes): A byte-like object that contains the key encoded.
- data (bytes): The data to decrypt.
Returns:
- bytes: The data decrypted.
"""
nonce = data[:AES.block_size]
tag = data[AES.block_size:AES.block_size * 2]
cipher_data = data[AES.block_size * 2:]
cipher = AES.new(key, AES.MODE_EAX, nonce)
return cipher.decrypt_and_verify(cipher_data, tag)
def encrypt(key: bytes, data: bytes) -> bytes:
"""
Given a key and data stream, this function encrypts the data stream and sets the
given key as the unlock key.
Parameters:
- key (bytes): A byte-like object that contains the key encoded.
- data (bytes): The data to encrypt.
Returns:
- bytes: The data encrypted.
"""
cipher = AES.new(key, AES.MODE_EAX)
encrypted_data, tag = cipher.encrypt_and_digest(data)
return cipher.nonce + tag + encrypted_data
Thanks! <3.
Hi guys I’m working on a project to have python assign an external USB connected device a static IP address. I’ve done some digging on stack overflow and haven’t found anything useful. Does anyone have any ideas or experience with this?
Is there anything that leads you to think that's possible?
assign IP
DHCP is what you need
hi, im looking to decrypt my own network traffic through a pure python proxy
ive managed to get the proxy working, but right now it just blindly sends encrypted data between client and server
how can i use ssl to decrypt?
heres what i have so far: https://paste.pythondiscord.com/BA7Q
Under normal circumstances you shouldn't need to do that sort of decryption - rather you can serve your own certificate to the client, and configure the client to accept that certificate.
i still dont know how to properly do that though
is this HTTPS?
yep
Are you using a web framework?
nope, everything is in that one file
i know its not ideal since resources like mitmproxy exist, but its been such a hassle to get it working that i opted to do it from scratch
Have a look at this then
https://plainenglish.io/blog/python-simple-http-server-with-ssl-certificate-encrypted-traffic-73ffd491a876
Basically you need to generate a certificate and a key
You need to load both of these into the server
You also need to load the certificate into the client, and tell it to accept this certificate
How to do that depends on what the client is.
yeah i did make my own certificate, but i never figured out how to get the client and server to trust it
also i tried this, it only works by using my localhost as a url instead of a proxy, which isnt what im aiming for
well if you are hosting it locally then of course you will reach it by localhost
It's not NOT a proxy because it's local
It's a proxy regardless of whether it's on localhost.
oh, guess im missing something then
Hosting it on the internet at a URL like https://someproxy.tld doesn't make it a proxy
What makes it a proxy is that it's between the client application and the server
If you want an internet URL that's another matter
well the more you know
And you can get one. You just need to buy a domain, and to have somewhere to host your code
dw im hosting it locally, i dont need it running 24/7
my other question is, how would i read my traffic while still letting it continue to its destination
You make a new HTTP request on behalf of the client, using the request they sent you.
Step by step:
client connects to you. You send back your cert. Client accepts it.
Client says "I want to GET / from google.com"
You connect to google.com. Google.com sends their cert. You accept it.
You say "I want to GET / from you"
Google.com gives you the page
You give the page to the client
This is called a forward proxy
A forward proxy server in Python. Contribute to anapeksha/python-proxy-server development by creating an account on GitHub.
yeah im following
The proxy can see all data exchanged between the client and the remote, which seems to be what you're after, right?
yeah basically
the full URL of the websites i access get encrypted in the CONNECT tunnel and i had no idea how to retrieve it
While you don't need a full framework you should at minimum be using an HTTP library
Correctly implementing HTTP from scratch is hard
But yes, the URL to be accessed is encoded in the request and you can retrieve it
no kidding
what about HTTPS though? any caveats?
That's already part of the step by step process I described above
With no HTTP you'd just skip the steps about certs
oh ok got it
ok im struggling a little at this step
im not sure when the client would try to connect to me, or how to send my cert back
with a normal forwarding proxy that you configure in your browser or OS, the client will send a CONNECT requests with the fqdn:port_number and http version to use to the proxy initially and then expect the proxy to connect to that host and port (after the proxy has done DNS lookup on behalf of the client) with a simple tcp connection and start just forwarding bytes in both direction blindly
ok so the client would connect after i make a new socket that connects to the specified host and port
how would i send my cert to the client then?
no, the client connects with a tcp socket to the configured proxy and send the connect request (which doesn't contain much other then hostname, port number and possible proxy auth credentials) to the proxy in clear text (no encryption what so ever)
the proxy then resolves the hostname to an ip address and connects a tcp connection to that ip address and port that the client requested
as soon as the proxy connects to the server it will just start to pass the raw content byte stream (the tcp payload) back and forth between the client and the server
You'd have a listening socket
A listening socket waits for connections to come in and accepts them
Then it receives one or more requests over that socket
Again this is something you should use a library for.
Don't deal with sockets yourself, as implementing HTTP using only sockets is very complicated
any libraries you guys recommend then?
yes, use libraries for as much as possible or this project will otherwise take a very long time and running the risk of never being finished
i would go for a asyncio compatible network library for the proxy to make life easier and the software more performant and scalable
and for just proxing you probably don't need to much http parsing or generating, you should mostly be able to pass the unencrypted traffic back and forth between the client and server
if you are going to watch the network traffic in the proxy you would need to have a CA or intermediate CA certificate on the proxy server that you can issue server certificates to the client with dynamically where you would more or less clone much of the information in the server certificate that you receive from the server and present your own to the client
the client mush have the CA certificate installed as a trusted root certificate for this to work, but that shouldn't be much of a problem as it's your own clients where you can (often) easily install the root CA on them (unless it's a Apple IOS device, then it's much more involved)
even with libraries this isn't a small and easy project if you want to inspect the traffic inside the encryption
you should probably have a cache with all the certificates that you "cloned" and issued to be able to reuse them as long as you get the same certificate from the server that you connect to, as generating certificate requests and signing them is a computationally heavy process that you don't want to do unnecessarily
you will have to learn quite a bit about TLS (what people usually call SSL, but is really the name of it's older ancestor) and certificates just to get this working properly
i think you will have to use a thread pool (or maybe even a process pool if the TLS library isn't implemented in external code that frees the GIL enough of the time) as well for much of the certificate stuff as that would otherwise freeze the asyncio code while running those computational heavy workloads
this is quite a lot to take in
yeah, i staid it's not a small easy project, encryption is often quite involved
with the right libraries you will get a lot of the work done for you, but you will still have to stitch quite a lot together by yourself to get it to do exactly what you want it to do (as it's very much non-standard behavior that you are after)
would something like aiohttp work?
maybe, but you're not really after standard http behavior, i think you would be better served by a TLS/SSL client/server python library (preferably not implemented in pure python, but rather C, C++ or Rust so that the code can free the GIL as much as possible while it's running the cryptographic parts of the code)
how about this then? https://pypi.org/project/proxy.py/
TLS interception, that one sounds very promising, someone might have done most of the heavy lifting for you, in that case it might even be a pretty small task to implement what you want with that
interesting that it can also be used as a forward proxy, that sounds like one would be able to implement a request router or a basic load balancer with that
sweet, now to actually get it working
Hey guys I was following a web scraping tutorial and the instance i opened the Program the next day my entire router got banned from that site
What can be the issue?
And how to access the site?
You probably spammed the site with requests and now your IP has been banned
If you didn't have permission - You should just take the L
Whats the point of web scraping then?
I think i accessed the api with an expired cookie
Getting data from a service does not equate to spamming the service
You did something that pissed the service operator off
getting information from a website
I did not spam
I used an expired cookie
only a bot would use an expired cookie
Ik but there was no header specifying a cookie
wow guys i love networks
hey
an questing
How can i make an app like Messages when more users are in and someone writes something in a chat that the message comes to all users?
🤔
pls send me the answer to dm TY
Im having trouble getting information from a post request. I want to access the data under the 'Response' tab in Inspect element because it is the only piece of data that differs between successful/failed logins.
Ive tried looking through all of the response data, html content, and even BS data but its always the same (excluding timeframes) with no signs of successful login.
The only work-around ive found is using Selenium but its far to slow and I need it to be fast.
(ps- the status code is always 200, ive tried that too)
def postSkyward(user, password):
payload = {'codeValue': user, 'login': user, 'password': password}
response = requests.get(url=skyward, data=payload)
soup = BeautifulSoup(response.text, 'html.parser')
htmlContent= response.content.decode('utf-8') # Decode the bytes to a string
return [soup, htmlContent, response] # soup, html_content, and response is ALWAYS identicle, despite the password changes
Hello guys, I'm currently doing a Google System Administration and IT Infrastructure Service course from Coursera, however I think I'm unable to retain most topics and therefore I'd appreciate it if someone could recommend a book related to those topics. (DNS, DCHP, Proxies, FTP etc.)
join
he posted a scam link to some server that got autodeleted by the bot
does the course include labs? I did a Google cloud coursera specialisation for Big Query etc. and it included a lot of labs. I have trouble retaining what someone said in a video, but the labs forced me to figure out how it is used in practice
Yes it does include labs, I can relate to that but I'd like to have information on the matter to be able to speak about it too
Computer Networks by Tanenbaum was the university textbook in my time, but maybe you are after something more specific than that?
I'm still willing to look into it, as long as it makes me learn something, I don't have much knowledge of this so it might be helpful regardless
Appreciate it
Can anyone help?
any doc or video on how to setup https with fastapi?
Idk if this is the right channel but uhhhh
Going into more specifics of APIs . . . . What the heck is it and how do i use it. And why does every site have it so different and weird.
I can get an API key and stuff from a sit but than what do i do with that? I don't even know how to get any info from it yet
Or alternatively can you have a script visit a website and just grab the data it needs? Im just trying to automate doing that by hand, i just go into inspect element and copy paste part of it to a peice of code whenever i wanna update it
Most of the sites will have an API documentation -- You will have to know basic-level python or of course other languages
I would recommend looking for config's or tutorials how to setup your API and try to retain that information
Usually the API Key gets stored in a script and will be used to send/receive queries in functions
Is it possible to make automatic instagram note changer, so it changes like every 10seconds to other note?
Hey everyone, here is a video I made (or at least to the best of my abilities lol) about how to programatily using python library scapy you can power up remote hosts. Hope this can help someone! https://www.youtube.com/watch?v=MOYJkq4RfPQ
Ever wished you could wake up your computer from afar, just like magic? In this video, I'll show you how to harness the power of Wake-on-LAN (WoL) using Python to remotely power up your computer! Whether you're miles away or just cozying up in bed, this handy trick will make your tech life infinitely easier.
We'll dive into the basics of WoL, e...
Hi, I'm trying to figure out my ipv4 address, i used this snippet of code but it's giving me my default gateway instead. Does anyone know how i could get my ipv4 address instead?
def get_ip():
hostname = socket.gethostname()
ip_address = socket.gethostbyname(hostname)
return ip_address
that does give you one of your own ip addresses, not the default gateways ip address
but it will only give you one ip, more or less at random, which might not be the right one if you have more than one ip address on your system
instead, this will give you a list of all of your ip addresses (both IPv4 and IPv6):
import socket
ip_addresses = [ip[4][0] for ip in socket.getaddrinfo(socket.gethostname(), None)]
usually you'll deploy fastapi behind nginx or similar that will do https for you and then just proxy it back to the fastapi server running on uvicorn or hypercorn
here is an example configuration for such a nginx configuration: https://www.uvicorn.org/deployment/#running-behind-nginx
at the end of the page you'll also find how to deploy your fastapi code with https using uvicorn directly or uvicorn on top of gunicorn
higher up on the same page will explain why you might want to involve gunicorn in the tech stack
The lightning-fast ASGI server.
i looked
@cloud spruce the goattt!! just wanna say a thank you to responding to me back when i was spamming the channel with beginner questions appreciate u bro!!
wow this suits me perfectly, thanks a lot !!!
haha, that must have been like 1.5 years ago or something, how is it going?
did the network topics make sense eventually?
glad i could help 🙂
can anyone help me, please 🙏
yess haha got my first internship last year for web dev and hoping to go on further from there 🙂
congrats, nice to hear, hope you get to put the network protocols stuff that you learned to work in your job too
hey anyone to take 20 mins debugging my code ? using zeroconf & socket
@router.get(path = "/v1/{method}")
async def get_methods(request: Request, method: str):
if method == "method_1" # instead of having the endpoint "/v1/method_1"
...
is this a bad practice? I did it this way because all the methods in this particular function, are super straight forward, short processes.
Can someone help me with router on stick
So when im trying configure the router it say fa0/0.10 no vlan and the ip address if it don't have vlan it cant commiucate right?
i don't know how this relates to python, but it looks like you have an old cisco router there or is it a L3 switch that you are planing on using as a router?
what hardware model and IOS variant and version is it running?
is this channel for internet networking or for neural networks?
internet networks
as neural networks are part of AI you might want to check out #data-science-and-ml if that is what you are looking for
thanks a lot
anyone knows about the zeroconf module ? i have issues with it
Hello!
I need someone who can build an Asterisk server.
Please DM me.
Hello friends
Please help
OSI model ⬇️
data is broken into pieces called segments and packets are what holds the segments like a package?
Layer 4 = Transport layer, can be Segments (TCP and MPTCP are two examples) or Datagrams (UDP, SCTP and more)
Layer 3 = Network layer, Packets (IPv4, IPv6, ICMP, IGMP, PIM, IPsec, OSPF, RIP, VRRP, HSRP, among others)
Layer 2 = Data link layer, Frames (Ethernet protocol, Spanning tree protocol, ARP, LLDP, UDLD, CDP, 802.11 wireless LAN, MPLS, PPP for example)
Layer 1 = Physical layer (Wi-Fi, 5G, LTE, Bluetooth. as well as physical connectors, interfaces, cables, electrical signaling and levels for Ethernet, USB, DSL and so on)
each Ethernet Frame (L2) holds one Packet (L3) inside of it, some other layer 2 protocols such as HDLC can have multiple Packets inside one Frame
and in turn, each Packet (L3) can hold one Segment or Datagram (L4)
Protocols are like nesting dolls
Each protocol carries some data that is internally used by the protocol above it.
Different protocols have different names for their units of data
It's important to realize that lower protocols often split and recombine data from higher protocols
So, one Segment (TCP) does not necessarily contain one Request (HTTP) etc.
How you break a data flow into pieces depends on what protocol you are looking at.
If you're talking about TCP, you will see different pieces than if you're talking about HTTP
TCP doesn't have to know anything about HTTP to break the data up. It just sees a big chunk of data that it splits into 4 parts, it doesn't care how that data is supposed to be split up at the "higher level"
This doesn't always happen. As rndpkt says, an Ethernet "Frame" always holds exactly one IP "Packet."
How things get broken up is very specific to the exact protocols you're dealing with.
Anyways, basically what you need to know about the OSI model is that every layer carries that gets interpreted by the layer above it.
If you send a request from your web browser to google from your computer connected to ethernet:
1 - Physical layer: Your physical ethernet card encodes data as electrical signals which are decoded by your router's physical ethernet card. These signals are used to send data for layer 2:
2 - Link layer: Your OS encodes data as an ethernet frame, indicating that it is for your router - your router should therefore read it, and any other computers can freely ignore it. These frames are used to send data for layer 3:
3 Network layer: your OS encodes the IP address for google, as well as your computer (for the reply) as an IP packet, indicating that the packet should be forwarded to google's IP address. These packets are used to send data for layer 4:
4: Transport layer: Your OS encodes a port, indicating to google's server which application it is trying to talk to, as a TCP Segment. This segment also includes information about the data stream itself, so that data can be received across multiple segments in the correct order. This is used to send data for layers 5-7
Here the model gets a big fuzzy. The OSI model is old and actually kinda wonky, so these layers often get combined since they are very vague.
But TLS (encryption) is built on top of TCP
and HTTP(s) is built on top of TLS or bare TCP.
You have to "unwrap" each layer to get data for the next one.
wow imagine if I asked what is a pencil
The only confusion I have "teacher Katy" is what is a segment and what is the difference between a packet and a segment. @hasty quest
Packets are a term used by Internet Protocol (Network layer)
Segments are a term used by Transmission Control Protocol (Transport layer)
Thanks
An IP packet contains this information:
A TCP segment contains this information:
https://fiberbit.com.tw/wp-content/uploads/2013/12/TCP-segment.png
The "Data" in the IP packet may have a TCP segment inside it.
you told me the terms associated with packets and segments and also what it contains but my question I am asking is what exactly are they.
I know that packets arepieces of a whole information but don't know segments
If you can help pls
Refer to the diagram above


