#networks
1 messages Β· Page 22 of 1
Im trying to implement a P2P network for Nodes and users who is trying to transact the cryptocurrency to other wallets , they need to communicate with the Nodes
@restive blaze Its not my first project, ive done like 4 projects but ye lol
This are some of them
Right but I've been programming for 8 years and I wouldn't want to do this
What's the basis for the blockchain method
Hey guys. I have a beginner question:
I'm making a script to mass download Google pronunciation mp3's (for educational use). I'm wondering on whether to use aria2 or requests as my download tool.
I like aria2 for its blazing fast parallel downloads, but since it's not native to python, I need to do all the file renaming afterwards (categorizing stuff). Thus, lots of extra read/writing to files. π¦ Should I stick with the tried-and-true requests module instead?
Oooh aiohttp looks nice. I'll read more into it.
Ok this isnt really in relation to python but I feel like it could be a easy or hard question
If I had a powerline adapter upstairs and downstairs providing ethernet to my pc through 1 ethernet port and the router is supplying the other adapter downstairs.
Could I just plug the ethernet cable coming out of my upstairs adapter into a splitter and have more ports ( with the splitter plugged in with power as well )
if you mean a switch sure
thats a switch yes
Cheers
Yea I know what a switch looks like I was just wondering if you could connect it via powerline adapter
@slender steeple WOW. Upon further research aiohttp looks amazing. Since I'm downloading vocab words I was building my own key-value table which was another extraneous task.
aiohttp already has a guide on how to build my own url's without having to manually store a bunch of extra info.
What's a good beginner switch to start with. I use a Cat 5 cable and it gets tiring having to manually disconnect the chords from one device to the other.
there are some pretty good cheap netgear ones around
Can I listen to incoming requests from a specific protocol ?
@oak spoke yes? no? maybe? what are you trying to do, be specific.
I'm trying to listen to the requests that an online game is sending to me
ok, so you need to do packet capture.
do you know what port its sending things to you on? and if its TCP or UDP traffic?
UDP probably since it's an online game?
And no I'm not sure what port is it
Or wait
I guess it's TCP
Since I want to know if I'm getting a game request or not
5000 - 5500 UDP
Normally you have a separate port for signalling
So you listen on like 5501 for game start requests then send back the port
How can I listen to it ?
You mean both
I meant it's UDP
hi
import ftplib
FTP_HOST = "ftp://ftpupload.net/prx001.ihweb.ir/htdocs/ClientUpdates"
FTP_USER = "my_username"
FTP_PASS = "my_password"
ftp = ftplib.FTP(FTP_HOST, FTP_USER, FTP_PASS)
ftp.encoding = "utf-8"
filename = "test 3.exe"
with open(filename, "wb") as file:
ftp.retrbinary(f"RETR {filename}", file.write)
ftp.quit()```
What's the problem
trying to download an exe file from my host
socket.gaierror: [Errno 11001] getaddrinfo failed
I haven't worked with ftp servers
can anyone help please
@ember ledge
FTP_HOST shoulb be just a hostname, no the full URL π
@ember ledge
FTP_HOSTshoulb be just a hostname, no the full URL π
@steep crow i must use ftp.cwd()?
What
hey, does anyone know why
import proxyscrape
collector = proxyscrape.create_collector('default', 'http') # Create a collector for http resources
proxy = collector.get_proxy({'country': 'united states'}) # Retrieve a united states proxy
print(proxy)```
returns none
Ok so... I've been trying to handle a socket with context managers such as the with statement and contextlib. Neither close the socket. So my ports clogged with the previous sockets I run.
i have this Exception error:
[WinError 10057] A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied
and this is my server side script
import socket
import threading
import json
import pickle
host, port = "127.0.0.1", 5555
IP = (host, port)
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(IP)
server.listen()
players = []
def send_data(players,data):
for i in players:
i.send(data)
def recv_data():
global players
try:
data = server.recv(1024)
print(data.decode())
except Exception as e:
print(e)
def main():
global host, port, IP, server, players
while True:
client, address = server.accept()
players.append(client)
print(f"NEW CONNECTION {address}")
while True:
_thread = threading.Thread(target=recv_data)
_thread.start()
#print(players)
main()
do you get that at i.send(data)?
msg = socket.recv(1024)
AttributeError: module 'socket' has no attribute 'recv'
is that your whole code
you need to make a socket
i would recommend reading a tutorial
can you show the whole code then
import socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.connect((socket.gethostname(), 4081))
msg = socket.recv(1024)
print(msg.decode("utf-8"))
it seems like recv is no longer in the socket module
so I am getting an attribute error
it never was, it's a method of a socket object
which in this case is server
it needs to know which socket you want to receive from
so what's the issue with the attribute error
AttributeError: module 'socket' has no attribute 'server'
I meant recv*
the server is all good
AttributeError: module 'socket' has no attribute 'recv'
you need to do server.recv
at the moment you're trying to receive data not from a socket
it'd be like doing import requests and then making a request and then doing requests.body
from bs4 import BeautifulSoup
page = requests.get('https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains')
soup = BeautifulSoup(page.content, 'html.parser')
patt = '<li><a href="/wiki/.'
for tr in soup.find_all('tr'):
tds = tr.find_all('td')
for t in tds:
if patt in t:
print(F"TD#{tds.index(t)}", t)
``` It prints nothing at all, what am I doing wrong? Im trying to get a list of top level domain extensions from that link and have stuck in the middle way
you could use something like: for link in soup.select('tr td a[href^="/wiki/"]'): instead. link['href'] should then give you the href attribute text
I assume it's not working because t is not actually a string and patt in t is simply finding nothing
@storm saffron did you check your messages, I sent you sumn
hello can someone help me plzzzzzzzzzz
!ask
oh ffs did they remove this
?ask
@ember ledge ask the question and people will help if they can
someone is helping me for the moment
any resources for learning how layers 1+2 work?
can Flask be used to load images like without html just direct img only?
for example localhost:8000/camera will load the image directly
thanks will check it!
yeah it's the same as just serving up a static image file
need to set content type so the browser knows what to do with it, then send a valid image file
but if you want live updates without having to constantly reload you might want a slightly different solution
@slender steeple anything specific?
@low prism you have made a mistake at server.connect((socket.gethostname(), 4081))
because its something like .connect((socket.gethostbyname(socket.gethostname), 4081)) but i am not sure
just stack overflow this line and it shoud show you mistake
Can anybody explain me, why If i do import urllib I cannot use urllib.request but when I do import urllib.request then I can? I mean this import logics looks bit off, it should be also imported with the entire urllib
Because of how their module will be setup
Ok, but what does it mean, or how am I supposed to know it?
urllib.request is a submodule of urllib and a distinct module from urllib
so you have to import it separately from urllib
yeah i guess you could know from looking at the folder structure
but the guide will tell you
I need help, i tried port forwarding port 80 and the router interface shows up
what did you port forward it to
if you forwarded it to 192.168.1.1 then that's the router's ip address
and you should remove that because that makes you very vulnerable
does anyone know how to use WSS with fastapi? i can't find anything that helps me figure out how i need to implement it
It's just a ssl websocket
so the client side is where i'll somehow establish that it's an ssl websocket? the docs dont show much other than "here's how to make a regular websocket"
it's the same with the starlette docs
so there's nothing different i need to do other than using a url with "wss" in it? lol
if you forwarded it to 192.168.1.1 then that's the router's ip address
@storm saffron port forwaded it to my computer
what ip
my computer's
which is
why would i give u my ip
it's a local ip
oh true
my computer's local ip is 192.168.1.30
hey guys
off topic maybe. but what does >netstat -sp tcp do?
@storm saffron are you busy
so it will
run netstat
-s will make it display statistics by protocol, and -p tcp chooses the tcp protocol
@storm saffron So my uncle called the toll number on one of those fake phishing sites
according to him, all he did was downloaded logmein hamachi and they ran that command or something
is there anything else they could do with his IP?
yeah they're gonna pretend that that command shows that he has malware
yes exactly!
so for example they sometimes look in event viewer
where there's tons of errors that are fine
the command on its own won't really do anything bad, it might show them what services are open on his computer
do you know what the output of that command was
It showed exactly what you said
"hacking links found" "trojan found"
then displayed active connections
can you show the exact output
Scanned with malwarebytes, showed nothing. They even went as far as to lie on the phone with my uncle saying malwarebytes wouldn't detect it, hah. I ran adwcleaner as well as hitman pro as well. Told him to change his passwords
yeah for sure
not sure if the local address even should be covered up
are they 'owner-pc'?
if so then it's services using sockets to communicate inside the computer
which is normal and fine
if you're referring to my uncle's system. most likely yes. I do not think I changed the PC's name
Makes sense.
Appreciate your insight very much man! Hope you have a great one
np
If a cookie of a user is not expired, what header should the server respond with?
if the server receives a valid cookie, then the server might not respond with any changes to the cookie what-so-ever. unless maybe it has an expiry date, and you want to update that date.
?
I have a website running on port 127.0.0.1:8001 and have allowed port-forwarding to my pc.
Then I used whatismyip to get my ip and tried <ip>:8001, but cant access the website?
(The second step was done on my phone)
Do I miss any step (Im new to this stuff)?
make sure you are on the same network when hosting locally
also, small world eh? :)
Yeah my phone is in the same network
but why wouldnt it work outside the network?
Because Im using a static dns provider?
My django website is now running on 0.0.0.0:8001, but I cant access it , even from the machine Im hosting it on
I think the auth-handshake failed
I mean, 0.0.0.0 is described as "Non routable"- how is that supposed to hlp me
I meant authentification but its working now
How would I make it available outside my local network?
port forward then access from public ip
how do I see my public Ip
I mean, shall I use my pc's public Ip?
Oh, firefox used https instead of http and thats why it threw the SSL-Erro, but if I just use http.://ip it works
Thank you
noice
is there anything immediately wrong here?
import socket
from time import sleep
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.connect(('echo.websocket.org', 80))
sock.send('GET / HTTP/1.1\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n\r\n'.encode('utf-8'))
while True:
print(sock.recv(100))
sleep(0.5)
I don't get a response, I also tried gateway.discord.gg but I get 400 Bad Request when I send the websocket upgrade request
Never mind just figured it out somehow just had to specify the host
Is it possible to fire a function on an HTTPS request? As in another piece of code sends a POST request to a python webserver, and on that request it fires the function?
Or something similar
hello im creating a web server for my esp8266 board. when i click a button ('launch') on web server, i want to run a function to enable access point mode. code:
try:
import usocket as socket
except:
import socket
from time import sleep
import network
stationMode = network.WLAN(network.STA_IF)
apMode = network.WLAN(network.AP_IF)
if stationMode.isconnected() == False:
stationMode.active(True)
stationMode.connect('ssid','password')
print('connected to ssid ', stationMode.ifconfig())
else:
print('ssid ', stationMode.ifconfig())
def page():
file = open('index.html', 'r')
html = file.read()
file.close()
return html
serverIP = stationMode.ifconfig([0])
port = 4444
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((serverIP, port))
server.listen(5)
while True:
conn, addr = server.accept()
print("got a connection from %s" % addr)
request = conn.recv(1024)
request = str(request)
print(request)
response = page()
conn.send('HTTP/1.1 200 OK\n')
conn.send('Content-type: text/html\n')
conn.send('Connection: close\n\n')
conn.sendall(response)
wdym by standard web framework?
a pre made web framework / webserver
rather than trying to make one with raw sockets with alot of security issues
like flask? https://github.com/micropython/micropython-lib
-_-
Anybody know how to create a recvall function in C++ for socket programming? Need to be able to receive as much a data as possible without it being limited due to the buffer size. Server and Client Socket.
I would expect it to already be builtin
Itβs not defined in winsock2.h
Attempted to make my own but when receiving data itβs messed up
hey guys, does anyone know how to use socket ? i'm doing picoCTF and i'd like to make python scripts to automate tasks, i'm on a task in which i have to use netcat to connect to host 2018shell.picoctf.com and port 36356, to get the flag, so the command on shell is simplync 2018shell.picoctf.com 36356 and it returns me this That wasn't so hard was it? picoCTF{NEtcat_iS_a_NEcESSiTy_9454f3e0}however i would like to do the same in python, can anyone tell me how to do so ?
i saw that i have to use socket but i don't know much about this
fastAPI > flask
@mental jungle https://realpython.com/python-sockets/
also checkout pwntools
i think that if i can write programs, i can also search for such websites by myself @slender steeple, what i would have liked was for someone to explain me how it works, now i made it work
hey im trying to learn pythons asyncio streams know any links apart from thier api cause i don't understand a thing there
Does anyone know how to build a graph in NetworkX?
specifically a knight's graph
like in chess
this thing
it's basically a graph of all legal moves of the knight on an 8x8 chessboard
wrong channel
Does anyone know if socket decodes websocket frames? I don't understand why I'm receiving 5 characters then json... are the 5 characters supposed to represent the length? Or are the frames skewed to the left or something? I'm confused 
anyone know how i could findout the ip range of a mifi hotspot?
websockets != regular sockets
But socket can be used for websockets... right?
And what am I supposed to use then? 
Is there something wrong with my code, I put it on a host and any time I try to load the bot it just says that the address is already in use. I have no clue how to fix it because I can't do much from the interface
this is the entire code
https://cdn.discordapp.com/attachments/724905074240913428/765215918460108800/unknown.png
- OSError: [Errno 98] Address already in use```
I use discord.py and load it on a cog along with the bot, but that error stops it
@velvet rapids websockets are just implemented on the HTTP protocol for two way coms keeping the connection alive
I know 
Everything is built on sockets themselves anyway
can somebody please explain this answer to me?
it's regarding using a subnet to grant privilege to some IPs for a MySQL server
I'm a bit confused though, because I don't have a lot of experience with networking, but would it be possible to grant access to the 2nd decimal point and beyong, instead of the third
for example instead of 192.168.1.*, 192.168.*
nvm figured it out
well websockets are a special protocol
oops i was scrolled up
'start networking' how
@rancid cosmos never used mysql but replace the 1 with a % like the example maybew
Yeah I got it to work thx
The thing is that the example was replaced a decimal point further down, so idk what that means in terms of network addresses
It did work however
has anyone successfully used ipv6 with uvicorn? https://www.uvicorn.org/
The lightning-fast ASGI server.
i dont need to, but im just kinda curious
nvm, there's actually a PR open to address it lol https://github.com/encode/uvicorn/pull/803
fixes #553
correct the url printed in the logs if ipv6 is used, using brackets arout the ip as recommanded in https://www.ietf.org/rfc/rfc2732.txt
so fixes #791 as well
Gg mods
TIL you can use IPv6 addresses in connection strings but it requires square brackets
https://blog.miguelgrinberg.com/post/video-streaming-with-flask
Hi does anyone knows how I can capture the jpg stream from the flask-opencv?
<html>
<body>
<img src="{{ url_for('video_feed') }}" />
</body>
</html>
i just wanted to see how I can capture it and display it with a CV player in another computer but from the same network
i use aiohttp, i created request handler, and i want to extract ip address from request, so how can i do this
@astral quarry you would use socket library for this...more specifically ```py
import socket
print(socket.gethostbyname('host name'))
is socket and network programming same thing??
is it possible to host a single server (like a discord bot or a flask server) on two machines which are in sync with each other and if one of the machine is down then the other machine compensates. Like two machines acting as one. (I am new to networking so not sure if this makes sense)
Yes, you would have a third gateway server which directs incoming traffic to one of them
hey guys, trying to test my API using postman, I get the following error: CORS Error: The request has been blocked because of the CORS policy
Is this a problem from my (postman/chrome) end -> API, or from API -> me?
I'm unsure how to solve it after googling
can I ask a question about s3 in aws here?
Is this the right channel to ask about pymodbus?
does random headers causes this kinda errors?
('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
ping me up if anyone knows?
but without headers works well π€
no? That purely depends on what the client is doing
probably because its changing how the client responds
umm...ok
Hey I'm having an issue with Apache. I have a web server that I'm trying to host 2 websites on. My file structure and settings all seem correct, but one of them gets the response of the other and I can't for the life of me understand why
.
βββ apache2.conf
βββ sites-available
βΒ Β βββ default-ssl.conf
βΒ Β βββ morganarnold.ca.conf
βΒ Β βββ onequotes.ca.conf
βββ sites-enabled
βββ morganarnold.ca.conf -> ../sites-available/morganarnold.ca.conf
βββ onequotes.ca.conf -> ../sites-available/onequotes.ca.conf
this is part of the file tree for /etc/apache2
.
βββ morganarnold.ca
βΒ Β βββ public_html
βΒ Β βββ index.html
βββ onequotes.ca
βββ public_html
βββ index.html
and this is the file tree for /var/www
any help would be hugely appreciated
<VirtualHost *:80>
ServerAdmin ...
ServerName onequotes.ca
ServerAlias www.onequotes.ca
DocumentRoot /var/www/onequotes.ca/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
this is the contents of onequotes.ca.conf
<VirtualHost *:80>
ServerAdmin ...
ServerName morganarnold.ca
ServerAlias www.morganarnold.ca
DocumentRoot /var/www/morganarnold.ca/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
and this that of morganarnold.ca.conf
pardon all the posting
What do you mean by "one of them gets the response of the other"?
oh so the index files are different but http://onequotes.ca gets the index page that I intended to be for http://morganarnold.ca instead
Morgan Arnold's personal website.
for some reason
http://morganarnold gets the correct one
and I have tried clearing my cache
Try specifying 'DirectoryIndex index.html' in the virtual host file, restart apache and see if that changes anything
still no good, unfortunately
Okay so I've spent more time trying to figure this out and if i delete morganarnold.ca.conf neither site loads, but it works fine if onequotes.ca.conf is gone
I am just WILDLY confused
Which is the most useful library to be able to access a website, login, scrape and download some pdf files?
@brazen otter Well, it depends on use case, usually requests is the way to go, but you can even simulate a browser with selenium (useful for advanced web scraping).
For most of the projects, the combination requests + bs4 is pretty good and efficient.
hi there guys
btw my real question is how to encode headers in hpack while webcrawling with requests?
Guys my server-client Program Only connects 2 computers on the same wifi
How can I modify it To Work On diffrent Wifis?
here are the codes
server:
import socket
import time
def send(Text):
c.send(bytes(Text , 'utf-8'))
Socket
IP = socket.gethostbyname(socket.gethostname())
s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
s.bind((IP, 1080))
connections = 3
s.listen(connections)
print(f"\nListening at IP: {IP}\n")
try:
c,addr = s.accept()
name = c.recv(1024).decode()
Machinename = "Server"
send(Machinename)
print(f"connected with {name}\nIP = {addr[0]}\n ")
connected = True
except ConnectionRefusedError:
print("connnection lost with " , name)
time.sleep(5)
quit()
while connected:
try:
Message = c.recv(1024).decode()
print(f"\n{name}: " , Message)
if Message == "Disconnect":
send("Disconnecting..")
connected = False
c.close()
print("Client disconnected succseffully")
time.sleep(5)
break
message = input("What do you want to send: ")
send(message)
print("\nYou: " , message)
except ConnectionResetError:
print("The Client was disconnected ( From The client side)")
connected = False
time.sleep(5)
quit()
if you want to accept connections from "anywhere", then you need to listen on the special IP "0.0.0.0" on the server side.
usually you don't
import socket
import time
def send(txt):
s.send(bytes(txt, "utf-8") )
IP = input("What is the ip: ")
print("\n")
try:
s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
s.connect((IP , 1080))
Connected = True
Name = input("What is your name? ")
send(Name)
MachineName = rec= s.recv(1024).decode()
except socket.gaierror:
print("No current Servers running")
time.sleep(5)
quit()
except ConnectionRefusedError:
print("The Machine refused connection")
time.sleep(5)
quit()
while Connected:
try:
msg = input("\nWhat do you want to send: ")
send(msg)
print(f"You: {msg}\n")
recmsg = s.recv(1024).decode()
print(f"{MachineName}: {recmsg}\n")
if recmsg == "Disconnecting..":
print("Server disconnected succsessfully")
Connected = False
time.sleep(5)
quit()
except ConnectionResetError:
print("Server Was Disconnected ( From the server side )")
Connected = False
time.sleep(5)
quit()
import socket
import time
def send(txt):
s.send(bytes(txt, "utf-8") )
IP = input("What is the ip: ")
print("\n")
try:
s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
s.connect((IP , 1080))
Connected = True
Name = input("What is your name? ")
send(Name)
MachineName = rec= s.recv(1024).decode()
while Connected:
try:
msg = input("\nWhat do you want to send: ")
send(msg)
print(f"You: {msg}\n")
recmsg = s.recv(1024).decode()
print(f"{MachineName}: {recmsg}\n")
if recmsg == "Disconnecting..":
print("Server disconnected succsessfully")
Connected = False
time.sleep(5)
quit()
except ConnectionResetError:
print("Server Was Disconnected ( From the server side )")
Connected = False
time.sleep(5)
quit()
So I need to replace IP with '0.0.0.0'?
on the server side, yes
No This Is the Client Code so Instead of taking Input in IP I replace it with '0.0.0.0'?
no
on the client side you use a normal ip
it's only the server side that needs to bind to 0.0.0.0
So Is This The correct code:
import socket
import time
def send(Text):
c.send(bytes(Text , 'utf-8'))
# Socket
IP = socket.gethostbyname(socket.gethostname())
s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
s.bind(('0.0.0.0' , 1080))
connections = 3
s.listen(connections)
print(f"\nListening at IP: {IP}\n")
try:
c,addr = s.accept()
name = c.recv(1024).decode()
Machinename = "Server"
send(Machinename)
print(f"connected with {name}\nIP = {addr[0]}\n ")
connected = True
except ConnectionRefusedError:
print("connnection lost with " , name)
time.sleep(5)
quit()
while connected:
try:
Message = c.recv(1024).decode()
print(f"\n{name}: " , Message)
if Message == "Disconnect":
send("Disconnecting..")
connected = False
c.close()
print("Client disconnected succseffully")
time.sleep(5)
break
message = input("What do you want to send: ")
send(message)
print("\nYou: " , message)
except ConnectionResetError:
print("The Client was disconnected ( From The client side)")
connected = False
time.sleep(5)
quit()
well, the print is wrong, but you can probably ignore that
And Here is the Client Code:
would've been easier to just do: IP = "0.0.0.0"
import socket
import time
def send(txt):
s.send(bytes(txt, "utf-8") )
IP = input("What is the ip: ")
print("\n")
try:
s = socket.socket(socket.AF_INET , socket.SOCK_STREAM)
s.connect((IP , 1080))
Connected = True
Name = input("What is your name? ")
send(Name)
MachineName = rec= s.recv(1024).decode()
except socket.gaierror:
print("No current Servers running")
time.sleep(5)
quit()
except ConnectionRefusedError:
print("The Machine refused connection")
time.sleep(5)
quit()
while Connected:
try:
msg = input("\nWhat do you want to send: ")
send(msg)
print(f"You: {msg}\n")
recmsg = s.recv(1024).decode()
print(f"{MachineName}: {recmsg}\n")
if recmsg == "Disconnecting..":
print("Server disconnected succsessfully")
Connected = False
time.sleep(5)
quit()
except ConnectionResetError:
print("Server Was Disconnected ( From the server side )")
Connected = False
time.sleep(5)
quit()
Ok
Any changes in the client code?
no
Ok So When Client asks Me To write the Ip of The Server What do i write?
the ip that you want to connect to
could be localhost a.k. 127.0.0.1, or your LAN IP
(usually 192.168.....)
I did not understand
or a public IP, assuming your router, if you have one, is forwarding the correct ports.
what did you not understand?
That When Client takes IP input I write The Server Computers IP?
yes, usually the ip where the server is running
if it's on the same machine, it can be the localhost IP, if it's in the same LAN, it can be the server computers LAN ip
Not on the Same Computer
So if the Server Computers IP is '129.12.123.204' I write that In the IP input?
yes, maybe
Let me Try And Get Back
Ip is socket.gethostbyname(socket.gethostname()) ?
If I write That In IP in client it Gives Timeout error
@cold geyser ??
that was on the server side, right? you don't need that line any more if you set IP to "0.0.0.0"
No On the Client side when I ask : IP = input("What is the Ip of The Server: ")
@cold geyser ????
yes, and? I was expecting more... usually after "when" comes a "then"
Ok Wait
if you get a timeout error, it's because it couldn't connect.
ip wrong maybe
how did you get that 129.12.. ip that you mentioned above?
socket.gethostbyname(socket.gethostname())
what about that?
IP = socket.gethostbyname(socket.gethostname())
print('server is running on ' , IP)
I already said, that thing is on your server side code and you don't need it because you set the bind IP to "0.0.0.0"
But then How will I get an IP to connect On the Client Side?
I am ON windows
is the server on windows as well?
server and Client Are on Diffrent Windows Machines
yes, then on the server, open "cmd.exe" and type: "ipconfig"
Then?
look for something that looks like this
I am Putting That In the Client.connect('192...' , Port)
It doesnt work Over 2 diffrent wifis
completely different wifis?
Yes
#cybersecurity message Can anyone give me a nudge in #cybersecurity ? Maybe it is more relate to #networks ...
what's your networks structure? what routers are involved?
What the heck is the problem here? π€£
@gleaming ivy mitmproxy is a tool than can do that for you. It's quite a sophisticated toolkit
and it's written in python
Shut up @gleaming ivy
but they are so crappy
that is going to be much harder than your probably think also can yall chill
Sani Just Tell me What to do Next?
sorry, but honestly I think you have to read up on how networks work in general.
Ok Bye

is there any other way than socket Proggramming To send Data Over diffrent networks in python???
that depends on the data but everything in networking uses sockets
asyncio is a higher level library. But you still have to figure out the correct IPs to connect with
i really wouldnt say asyncio is higher level
in alot of places its alot more complex and still requires you using sockets
@cold geyser actually the problem is not building the TCP proxy, but to make the game client connect route the traffic through the proxy, and since the game has official servers and not a prompt of the address (like Minecraft)....yes, really easy...
i don't even know how to re a game
theres a diffrent between writing a simple proxy and writing a proper proxy
i thought about putting in a different AP on a rasp
Production grade Proxies are very complicated and have alot of things they need to do to maintain security and performance
it's just an amateur proxy for a game, not a proxy that you would advertise online
β€οΈ RevEng 
i thought about putting in a different AP on a rasp
is there a simpler way?
let's say the game runs only on Windows, but the proxy could also work for Linux...
I think I did something like that using mitmproxy. I had to configure my network settings to route the traffic from my windows machine, where the game was running, to another machine (linux in that case), where mitmproxy was set up.
additionally I had to add a fake root cert on my windows machine, so I could sniff out the encrypted data as well
what's the command, even for powershell, for routing traffic for one source ip?
iproute or something?
as i remember, it is also possible by modifing the hosts file
I have no idea. that was years ago, when I did that
mitmproxy docs probably have something about that
@cold geyser don't think modern games tend to accept windows root certs
generally pinned i believe
Are there any other places I could try asking an Apache question? I tried here, but it didn't fix my problem
can someone give an example use case for socket.sockpair?
Hello guys
I've done something really stupid. https://www.geeksforgeeks.org/kali-linux-aircrack-ng/
And my wifi icon in the system tray is gone!
when I type wifi in my terminal. it shows zero. But the internet is working fine.
I tried looking for a sol in arch wiki and all that. I am unable to fix this!
is there a way to use python to change my proxy ever 10 minutes from a lit?
so like it picks a proxy from a list like proxys = [11.13.3443, 112.232.3222, 222.23.44.5]
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.
[sorry, but using proxies, especially in this way, seems like something that probably crosses the line]
it's not that it's directly illegal, [though often the kinds of lists of proxies you'd be working from are compromised or unintentionally open systems] it's more that the kinds of things you'd do with it are probably not okay at best in a very dark gray area
I have a (python, console) script that interacts with an API (over a library), when attempting to authenticate it wants to me solve a captcha, yet no real way of actually doing that (as its all in the console), how should i go about fixing that?
(its never asked me to solve a captcha before, I'm not sure if the library author did something, or the API, or something, but it's something I have to somehow overcome)
I have a Response object, and the text property gives me HTML code, which leads to the page where the captcha should be
there's no documentation for the API
and authentication is a different sub-page of the main one, which i noticed isn't API friendly
what's the library though
Im looking for some modules that will help me capture video streams or just single frames π
from what
directly from web page, for example https://www.earthcamtv.com/
well inspect elemnet shows this is a video stream
also rule whatever it is may come into play soon
hey, i'm having some trouble turning my socket local server into one that can be accessed by anyone, would anyone here be willing to help me with that?
- host on 0.0.0.0 not localhost or 127.0.0.1
- port forward on your router
- access from external ip
have you done those
if so what's not working
i havent tried 2 or 3, ill see about that. thanks π
i'm new to networking and I don't know much
also rule whatever it is may come into play soon
@storm saffron I should request bytes from that src link? hmm I could try something like that
hai so, ive never been good with netwroking, i copied this project and it worked on my machine locally, would i be able to set up a static ip adress and then join the chat room from anywhere in the world? or is it not that simple?
https://medium.com/python-in-plain-english/build-a-chatroom-app-with-python-458fc435025a this is the link btw
import asyncio
import websockets
async def server(websocket, path):
while True:
val = input("Enter your message: ")
await websocket.send(val)
start_server = websockets.serve(server, "localhost", 5000)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
my messages aren't sending to the client
it works when it's not in the while loop
do you get an error?
no
well i literally know nothing but try putting in a sleep in the while loop
just to see if that changes stuff O:
it didn't work
and if its not in a while loop it works but only once?
yeah
what you might wanna do, is have a while loop, that then sends the val to a function and in there put the await, gimme a sec
import asyncio
import websockets
def sendMsg(val):
await websocket.send(val)
async def server(websocket, path):
while True:
val = input("Enter your message: ")
sendMsg(val)
start_server = websockets.serve(server, "localhost", 5000)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()```
now it's erroring "coroutine 'sendMsg' was never awaited"
i think await makes it so the python script waits for when it has time to send stuff, but since there is a while loop it kinda never has time?? idk i need to google what await does
what you might be able to do is that, after you send a message, you just send the user back to the function where you input the message, so thats kinda a loop, idk :>
await... awaits the coroutine
if you dont know what coroutines and futures are you should probably learn about asyncio and async in python before starting this
@gloomy root how would you write this?
if you dont know what coroutines and futures are you should probably learn about asyncio and async in python before starting this
@gloomy root
"When you call await, the function you're in gets suspended while whatever you asked to wait on happens, and then when it's finished, the event loop will wake the function up again and resume it from the await call, passing any result out."
isnt that just a function that calls a function with a return O::
but ig that when you use async nothing is synced and this is kinda a way to sunc it again? (kinda)
@gloomy root did i get it?
not really
coroutines remembers me of kotlin and threads
Discord.py, Sanic, aiohttp, Websockets, FastAPI, Starlette, Pyre, etc....
discord bot, got it ;>
hey, i'm pretty familiar with sockets and was exploring ssl for secure transmission. a lot of the information on google is difficult to understand. would someone help me with certificates/handshake stuff like that?
does anyone know how I would make it so windows defender doesn't hate my socket program when I turn it into an exe? Like to make it so I don't have to do any extra configuring of windows defender to make it fine for anyone to use if I send them the client?
Im setting a varible to my computer adress and how do i write it. This is not my adress
Do i write it like this
D5-K6-7A...
Or
βD5-K6-7Aβ
Or
d5-k6-7a
Or
D5K67A
Or a mix of the previous
@elder spoke you can try to make for example an outbound UDP request that the firewall will block
then the firewall will most likely prompt the user to allow python or your executable through
do you mean defender specifically or the firewall?
@high wing what do you mean
what is that code
and what do you mean 'setting a variable to my computer'
If I have two separate python scripts that I have listen on different ports, can my computer act as a separate server for both?
I want my raspberry pi 4 to reverse shell to my laptop so I can have a linux terminal on my laptop and also using that set up an MVQTT server
I've never tried having 2 sockets open on separate scripts before so I just want to know if it's feasible
yeah there's no problem if they're on different ports
hey i have a question
ask away
so how would you actually put a server on the internet?
hosted on your computer or similar?
host a server, then tell your router to allow connections in
then your server is on the internet, accessible at your public ip
how would i tell my router
by port forwarding
ok thanks π
that wasn't very detailed lol
feel free to ask more questions about this if you want to know more or actually set up a server
I wouldn't suggest port forwarding your router, use a remote host provider instead, like GCloud or AWS, first year should be free, if you provide a payment system. @stone delta
does anyone know if its possible to re open this port after closing it?
def __init__(self, PORT):
self.thread1 = threading.Thread(None, self.run)
self.Port = PORT
ip_address = 'localhost'
self.url = 'http://' + ip_address + ':' + str(self.Port)
Handler = http.server.SimpleHTTPRequestHandler
self.httpd = socketserver.TCPServer(("", PORT), Handler)
def run(self):
print('listening on: ' + self.url)
self.httpd.serve_forever()
print('Sever stopped')
print('Port ' + str(self.Port) + ' should be available again.')
def stop(self):
print('Stopping server')
self.httpd.shutdown()
self.httpd.server_close()
def start1(self):
self.thread1.start()
I am trying to open the server for like 10 seconds, then close it, then re open it on the same port
https://nekobin.com/faqivumife.py
I am getting this error even though downloading gets completed. What should I do ?
b
@desert valley yes, just instantiate the server on a given port, like my_server = Serv(8080), then my_server.run(), do whatever you need to do for your 10 seconds, then my_server.stop(), then my_server.start() again when you want it up. as long as you don't create a new Serv class it'll still use the old my_server listening on 8080.
I'm basically just sending HEAD requests to an API with aiohttp with a random proxy every time, to test which proxies work. 99% of the connections raise one of these:
ClientResponseError, ClientHttpProxyError, ClientProxyConnectionError
Is the problem in my code or is it in the proxy?
ping me when replying
@ember ledge post code
ok
async def process_chunk(session, proxy, chunk):
#proxy = 'http://' + 'xxx.xxx.xxx.xx:80'
for data in chunk:
headers = {'check': data}
try:
async with session.head(API_URL, headers=headers, proxy=proxy) as response:
print(response.status)
if response.status == 200:
master_list.append(data)
except ....
.........
There are about 20 tasks of process_chunk running.
limit is TCPConnector(limit=50)
async def main():
connector = aiohttp.TCPConnector(limit=50)
async with aiohttp.ClientSession(connector=connector) as session:
with open('data.txt') as data_f, open('proxies.txt') as proxy_f:
tasks = []
chunks = []
## Generate data and divide into chunks
for chunk in chunks:
proxy = next(proxy_f).strip('\n')
proxy_url = 'http://' + proxy
process_chunk_task = asyncio.ensure_future(process_chunk(session, proxy_url, chunk))
tasks.append(process_chunk_task)
await asyncio.gather(*tasks)
@slender steeple
and there are 800 datas
evenly split between 20 chunks
Do any of you know how to build to build an ad-hoc network ?
Maybe with Arduino, Rpi or other
What sort of communications are you looking to do?
@ember ledge
i solve it thanks
whenever i play among us i get disconnected it says sent 6 pings that the remote server didnβt respond to and sometimes some ackβd thing...How can i fix this?
Ping if u know
I'm participating in a competition.
I need to come up with some innovative ideas to make a safe college campus during this period of covid19
Do you guys have some ideas?
Does anyone know of any unofficial Twitter API?
I checked at a variety of places. All of them point to the twitter API. I could find Instagram Unofficial API which needs only username and password of the user. Is there something similar for twitter or some other way to automate a bot to post tweets.
Someone told me that selenium can be used but websites are able to detect it and then put a captcha. Faced this when using selenium with outlook.
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.
Why does the recv function on the server side stop acting as a blocking call and starts receiving empty strings when the client program and connection ends ?
Isnβt it supposed to throw an error
βdef receive(conn, addr):
while True:
data = conn.recv(512)
print(data.decode("utf-8"))
if data:
broadcast(data)β
Thatβs the server side
Client side is just connecting to the server and then sending a βheyβ and then the porgram ends
βdef receive(conn, addr):
while True:
data = conn.recv(512)
print(data.decode("utf-8"))
if data:
broadcast(data)β
@undone cloak this keeps on spamming empty strings even after the connection from the client ends
Any help would be appreciated
hey everyone! i just wrote this today but if anyone is studying for the comptia A+ exam its just a little quiz on important ports and protocols. it's really simple and short but i hope it helps
minor suggestion: add some error handling so accidentally entering a non integer doesn't crash the program
^
i was wondering how a change in a database could trigger a shell script to take place automatically on my computer
you mean you want the script to fire any time you make a change in the DB?
https://www.postgresql.org/docs/9.1/sql-createtrigger.html you can poll for triggers and run stored procedures based on them if that's what you want
thanks : )
will do! @slender steeple thanks for the input
Simple and intuitive. REALLY like it otherwise..!! Always enjoy people pushing themselves to code small projects, way to go!
thank you @rose viper i appreciate your kind words. my last project was about 3 months ago so i decided its time to make something useful to actually help me study! I just started learning python in january and it has been very rewarding. Do you think it might be worth it to list that on my resume even though its so simple/short?
it also helps cause every time i have to run the code to test it, i get some practice in for my exam
two birds stoned at once hahaha
Hello, how can I create a file Browser of another pc (socket) with Python?
Hi everyone, I'm new to this community. I'm starting to approach the world of Python and Kivy and together with a friend of mine we are trying to develop a small app that allows you to send and receive text messages using the chat of a Minecraft server. Unfortunately online there are no tutorials about it even if I think it is possible as there are several similar apps on the play store. Could anyone help me? I guess you need special libraries (I tried with mcpi but it didn't work). I use VS Code on Windows, Python 3.7. Thanks in advance to those who will answer!
Like sending messages into a Minecraft server?
client.py:
def main():
s = socket.socket()
s.connect(("127.0.0.1", 8820))
finished = False
actions = ['rand', 'time', 'name', 'exit']
while not finished:
data = input("Enter data which you want to send to server: ")
if data.lower() in actions:
s.send(data.encode())
reply = s.recv(1024).decode()
print(reply)
if data.lower() == 'exit':
finished = True
else:
print("Invalid data.")
s.close()
server.py:
def main():
server_socket = socket.socket()
server_socket.bind(("0.0.0.0", 8820))
server_socket.listen(3)
print("Server is up and running")
finished = False
while not finished:
client_socket, client_address = server_socket.accept()
quit = False
while not quit:
data = client_socket.recv(1024).decode()
if data.lower() == 'time':
t = time.localtime()
reply = time.strftime("%H:%M:%S", t)
print("Action Received: Sending Time...")
client_socket.send(reply.encode())
if data.lower() == 'rand':
reply = str(random.randint(0, 11)).encode()
print("Action Received: Random Number")
client_socket.send(reply)
if data.lower() == 'name':
reply = "Server Name: Yuval's Server".encode()
print('Action Received: Server Name')
client_socket.send(reply)
if data.lower() == 'exit':
finished = True
quit = True
print("Exiting Server...")
client_socket.send("Server Exit Call...".encode())
this works, but its quite counter productive imo.
is there any alternative to nested loops in the server.py? (im trying to achieve that the server wont just "shut down" after 1 task)
this is a practice question I got from school, if you're curious.
nono I was asking a question too :)
Im also new and if you have an answer id be glad for your help but I dont really have an answer to ur question :/
I'm new too ... and unfortunately I don't have an answer to your question, Sorry :(
you shouldn' set finished i think
because you set quit when the user quits, but you also set finished
which ends the entire program
@storm saffron can you help me? Sorry if I insist π¬
what's mcpi
is a python library
hello is there a way to connect my app to my pc as a server?
like im making sth like "siri"
but i want to send the user inputs to my pc or server whatever kind for me to commit m achine learning
might as well input feedback to the user
thank you @rose viper i appreciate your kind words. my last project was about 3 months ago so i decided its time to make something useful to actually help me study! I just started learning python in january and it has been very rewarding. Do you think it might be worth it to list that on my resume even though its so simple/short?
@plucky cave
I find that it never hurts to link the github because it opens the door to talk about your knowledge of git which most employers would appreciate. Sorry for the delay in response, have been AFK.
no problem at all! thanks so much for the insight
@sacred trench Yep, you'd have to make the server though
good evening everyone!!
Good morning!
Could anyone please tell me how basic networking in python is done?
I know the basics of python till classes and I am interested for learning networking with python
@wraith grove how do I do that tho
Could anyone please tell me how basic networking in python is done?
@zenith roost https://www.quora.com/I-want-to-learn-Python-with-network-programming-How-and-where-do-I-start
@zenith roost https://www.quora.com/I-want-to-learn-Python-with-network-programming-How-and-where-do-I-start
@thin sun
Thanks for this.
hmmm
@sacred trench Studying the basics of tcp/ip will help alot
here's a tutorial of the programming side of it
Yeah networking has a lot of stuff going on
Note if you are gonna be doing this on like your home PC, you will need to port forward
you can also get a VM from a variety of different cloud providers for like $3/month
Hi I am a newbie to networking, going to attend a test for a server side engineer role. in a week or two The company expects basic computer knowledge (DSA,asynchronous I/O, databases, networks,etc) . I am confident about DSA. But apart from that I dont have much computer knowledge. Where should I begin,?what concepts should I look to cover?
Is the company aware of your lack of knowledge?
Yeah. The company is open for non cs major students as well
but they expect basic computer knowledge
fair enough
well full warning
you will not learn much in a week or so
Networking concepts in itself is massive
add that with AsyncIO which you'll want good knowledge of Python in general to use asyncio well
etc...
My best advise is get the Python knowledge down, read about networking concepts and tinker with a bit of asyncio doing some basic networking stuff, client/server system or something of the sort
Networking concepts in itself is massive
@gloomy root Yeah I can imagine that!
Yeah atleast i will try to learn some basics
in networking
any suggestions .. like any good book on networking?
not really but Real Python would be a good place to start:
https://realpython.com/python-sockets/
https://realpython.com/async-io-python/
In this in-depth tutorial you'll learn how to build a socket server and client with Python. By the end of this tutorial, you'll understand how to use the main functions and methods in Python's socket module to write your own networked client-server applications.
Cool! Thanks. Atleast somewhere to start I guess
Hey guys! Is there anyone who has knowledge about video conferencing and online video broadcasting? I want to ask something about the algorithms that are used in it.
What kind of algorithms
The algorithms which are used to send digital visual data from webcam or screen capture over internet
I am working on networking with a friend, and would like a basic introduction on how to set up a connection between two computers on different networks
I have understanding of sockets, and have been using a basic server-client model which can be found online
However, the logistics of setting up a connection has been a massive headache for both of us, and any help would be appreciated
Would opening ports on both networks be the right thing to do?
Thanks in advance π
And please @ me if anyone has an answer, or something I should consult - I may be afk at some points
What kind of connection are you thinking of @icy hamlet ?
Just a simple server-client connection, between networks
Ideally p2p, I don't want to use a 3rd party connection (e.g, irc)
Idk why autocorrect doesn't like that
Just direct connection
Do you know what UDP and TCP are
Vaguely, but enlighten me
I know I have been using TCP protocol over IRC
Couldn't tell you the details, but I understand it is a protocol with a fixed port number
Well it has a default port but basically it's how web requests are made on the internet
Any time you request a URL and get a response that's http
Ah ok - port 80, right?
Yes, normally
Got it
But you can use a different port if you specify one
So it's just a request/response system
HTTP is built on TCP
But you can use a different port if you specify one
@storm saffron Ah ok
HTTP is built on TCP
@storm saffron That makes sense
TCP isn't a way of requesting webpages, just a way of sending data back and forth
Just a general protocol
So HTTP uses TCP to send the data it needs to send
Yep
UDP is like TCP, except it's not guaranteed to be reliable
How can you implement TCP over two devices though?
The different networks thing is becoming a headache
So with TCP you send a message and keep trying until the other end confirms they got it
How do you create a 'portal' so to speak?
Got it - like ehlo in SMTP?
So with TCP you send a message and keep trying until the other end confirms they got it
@storm saffron
Afraid I'm not familiar with SMTP
Just a mail server
Assuming you as a user haven't done any special port forwarding, when you make a request to your web server, your router spots that and when it sees the response, it knows to let it back in
Whereas other random packets are blocked because unless you've specifically port forwarded to let them in, they're probably malicious
so you need to disable the firewall on some ports?
Yes
But specifically port forwarding sends incoming packets to a specific device on the local network
That makes sense - so not all devices can read the incoming data
The other thing the router does automatically is when it knows a packet should be allowed back in, it also knows that it should go to a specific device
Do you know how local and public IPs work
IP addresses
not completely, no
is one associated with your device, and the other with your router?
Yes!
Exactly
There aren't enough IP addresses for every single device to have a unique one on the internet
So your device connects through the router to the internet
Which means that when the response from a server comes back, it doesn't say in the message who it's meant for
Because the destination is the routers IP address
So the router has to guess based on who it saw make a web request previously
So does the router have to redirect it to the intended location via port forwarding?
So the router has to guess based on who it saw make a web request previously
@storm saffron Huh, I never knew that!
You don't call it port forwarding in that case normally
Does it ever get it wrong?
Yeah it's pretty cool
It really is π
Well normally if it gets it wrong it just wouldn't know to send it back in
Do you play many online games
That would make sense, I guess - so nothing bad would happen
I have played a few, yea
Some MMOGs
No, I don't think I have
So the problem is an online game doesn't work like a web server
Because the server might want to send a message to a client like 'you got shot at'
And the router might not let that in because it knows it isn't a response to something that got sent out
Rather than the other way around, which would be a server-client?
So it has to act as both?
Well yes, one solution is to port forward on the client to force the router to send all the packets to your computer
And that would carry it out directly?
But often routers will manage to figure it out, because even though it isn't a TCP connection, they can see that the UDP game traffic looks like a connection
So the packets coming in are probably ok
So they can be sure they are secure
And they can pass through the firewall, so to speak
Yes firewall is slightly different
The router has a firewall which is the same thing as what does the port forwarding or packet blocking
But a computer also has a firewall
But a computer also has a firewall
@storm saffron So, in practise, I might have to open ports on both computer and router to allow the traffic to pass?
Yes
Got it
And btw I know this isn't really answering your initial question but I hope it's helpful
it really is - I don't learn too much about the theory at school, so this is really great to learn
There is enough IPs if we used IPv6
Is IPv6 now standard? And how would you update old devices to deal with it?
The ips that are running out are ipv4
Which is still widely used
But ipv6 is slowly becoming more popular
Plenty of toasters
I think the model of having your devices behind a router is likely to stick around though
Because it's quite convenient
It shouldn't be the responsibility of the device to direct internet traffic in that way, I agree
And keeping routers means the same standard can remain across all connections - without a change being made for some, or different protocols being established
Also isn't really compatible with a modern way of connecting to the internet
in what way @storm saffron ?
It used to be that you'd use a modem to connect from your computer to the exchange
but that's seriously antiquated
But now you have so many computers in the house and you use modern fibre or other broadband providers
There's no way realistically to connect things like laptops or phones to your fibre lol
Ethernet is inconvenient, too
But anyway you wanted to know about connecting devices together
Is this two python programs
And do you think from what I've said that you want to use UDP or TCP
Two python programs, and since packets should be safe, TCP should be good
I think???
@storm saffron
Sure that sounds good
:sighofrelief:
So you'd need to port forward and open the firewall on both computers and networks
Ok - that explains why it hasn't been working
My friend has struggled to open the network on his end
ngrok is another option
ngrok @slender steeple ?
it lets you tunnel a tcp connection through an external server
oooooh that looks useful
the only minor issue you may have is that the ip and port will change everytime you run it
that's frustrating - is there any way to allow it to read the ip/port automatically each time, to run automatically? @slender steeple
I'd say if you're new to networking then it'd be good to do it the basic way even if it's harder for users to use
ok, ill give that a shot
i wasn't intending it to be user-friendly yet - that's a whole universe away rn >_<
thank you so much @storm saffron
Thank you so much - you are so knowledgable, do you mind if i dm you in future?
Sure
And I'm not that knowledgeable I've just spent a lot of my time wrestling with this
hey guys I've a simple question. What does sharing a printer in a domain controller mean?
Does it mean that the printer isn't a network device but can connect to the domain controller over usb and can be shared over the network without any network interface?
The reason I'm asking is that DC has control over who can access a printer, how is that possible?
Do these printers usually have a user interface to be controlled?
Printer is published in Active Directory
Probably not, that would be a very silly way to connect a printer. 98% of the time printers are networked and have a webgui which some people can logon to see toner status etc. Usually there are AD groups that decide who can print and where.
You can send print jobs directly to a network printer. But a computer (doesn't have to be a server can also be a windows 10 machine or anything really) can also share a printer on the network. So then print jobs are send to that computer first. So depends on the setup really.
Hi does anyone know if itβs possible to host a home pc as server with socket
Is it safe
Iβve written a server script for client and host
But Iβm not sure cuz I remember someone telling me to use a VM
told*
help
im using openvpn
and it says openvpnapi.vpn not found
i installed openvpn
and pypi
for it
Any references or explainatipns on how to create your own automatic openvpn network that you can access thatβll let you stream network traffic through?
Pretty much a vpn programmed in python
anybody know if in python there is a way to listen in on a http post request being done?
@tough hemlock Yes there is, using the requests module
what I am trying to do is see the data being transmitted during a post request
you can if its http and not https
So for example:
response = requests.Session().post(link, data=...)) print(response.status_code)
@ember ledge he wants to MITM a http request
This works for me
not make a http request
Oh
sorry let me explain further
wait are you the one sending the original post request and you just want verbose info?
or do you want to intercept a post request from a diff program
I am already making the http post request sending a file to an api but I am want to see how much data (not the actual data or the response) has been sent so I can create a upload progress bar
sorry I should have clarified a bit more earlier
that is what I am thinking too after all my research
huh apparently you can
hmm... interesting they are using a progress bar for load/queuing up the file to be sent (or am I reading that wrong)
Do you guys know how to check if a session is closed when using the requests module?
Plus what does a closed connection even mean? After I close a session I can still do requests in that session
@slender steeple I will give it a try and let you know
@ember ledge take a look at these videos, they will help explain better than me in text chat lol. https://www.youtube.com/playlist?list=PLJ1odve0o6dX5ndJ5lwiCOR58ycB1rcrV
They are very short vids and explains it very well. I was watching them last night with investigating the upload problem.
@tough hemlock Thanks for the vids but they sadly don't cover the closing of a session
hi
python noob here
networking a field in particular that i lack severely in
how should i go about starting to learn it?
from the barebones?
is there a roadmap i could follow?
what kind of thing do you want to learn
is there a way to send email from smtplib, using variable font, colour, and other design parameters...?
def send_mail_(args):
#print('mail')
from_addr = args['From']
password = args['Password']
to_addr = args['To']
cc_addr = args['CC']
bcc_addr = args['BCC']
with smtplib.SMTP('smtp.gmail.com', 587) as server:
server.starttls()
server.login(from_addr, password)
SUBJECT = args['Subject']
TEXT = args['Text']
message = 'Subject: {}\n\n{}'.format(SUBJECT, TEXT)
message = "From: %s\r\n" % from_addr
message += "To: %s\r\n" % ",".join(to_addr)
message += "CC: %s\r\n" % ",".join(cc_addr)
message += "Subject: %s\r\n" % SUBJECT
message += "\r\n"
message += TEXT
to_addr = to_addr + cc_addr + bcc_addr
#print('message_compiled')
#print(message)
server.sendmail(from_addr, to_addr, message)
This is the code which I'm using rt. nw.
what kind of thing do you want to learn
@storm saffron
Just want to be proficient at learning it atleast to a level where I am comfortable in web dev or automation
amateur hour here: I'm testing connectivity using socket.connect_ex(), but I can't for the life of me find the meaning of the return values anywhere in case of a connection failure
I must be missing some keyword in my searches
aha nevermind, gotcha
return values are to be used with 'errno' to find the meaning
is it possible to change your ip and mac address in python because i was under the impression that i could not do that ?
changing your ip doesn't really mean anything
it depends whether you mean on the internet or LAN
and some network adapters let you use a custom or randomised mac address
but 'in python' doesn't really have anything to do with it
Bandwidth definition:
none imo
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.
the whole graded assignments thing
i think because it ends up leading to low quality questions along the lines of 'do my homework for me'
but if you're confused then i'd say 1 or 3 or neither
probably leaning towards 1
@normal rapids we can help you learn what you need to know to complete assignments, but we can't, for example, help you answer questions on a test while you're taking it. It's a rule because we don't want to be a platform for cheating.
[WinError 10049] The requested address is not valid in its context
cli.connect(("0.0.0.0", 9026))
Not sure wtf is going on
i have a server up and everything
you can't connect to 0.0.0.0
that's only for listening on all interfaces
for connecting you need to specify a real ip
@smoky estuary
but that works for all my other programs
oh i used gethostname() for my other programs
A single python file can handle being a socket client and server right?
(Lemme give some context here)
Say i have a server, Server1 and it is outside this py file but still on my PC
Then i have a client, client1 which is in this py file
Then i have another server, Server2, which is in this py file
Then i have another client, client2 which is outside this py file but still on my PC
^would the py file with the client and the server be able to fill both positions or do i need threading or smth
Yes it can
hello i am new to networking
can anyone direct me to some good tuts or anything i can start with
@pale steeple they teach the basic and some advanced fundamentals you may want to learn for free on Youtube. They cover networking, cyber security, system administration, Operating systems, etc. I find this really useful and started out learning with this. Each video is roughly 7 hrs long and covers variety of aspects in these fields for free by google. If ur willing to dedicate time and want to persist with networking, i recommend browsing some udemy courses if you feel like you want to go the long haul (they cost money but they are inexpensive), there are many CompTIA certificates that are valued overratedly by the IT industry that include networking
@ember ledge Thanks a lot. I'll check it out.
anytime π
Anyone here familiar with AWS or cloud hosting ( mainly EC2 instance)??
Need some help
please tag me if u know
hi there, not sure if this is the right channel ... but im trying to upload to gdrive, visiting speedtest.net i get 324.67mbps download, and 11.96mbps upload, however, when i am using python (pydrive), or rclone, im getting 0.76mbps (95mb in 74 seconds, and upload to gdrive via rclone), am i not understanding the conversion or is there a bottleneck somewhere?
Speed tests are done in megabits, actual upload speed are usually measured in megabytes. 1 byte is 8 bits, so that 12mbit upload is just over 1 megabyte per second
Therefore 95MB in 74 seconds is about accurate @ruby isle
about sockets: is it better to keep a single socket instance to a server or create a new connection everytime I need to use?
depends what you're doing
@ember ledge this post might give you some ideas https://stackoverflow.com/questions/17667903/python-socket-receive-large-amount-of-data
but I would recommend this one https://realpython.com/python-sockets/#application-client-and-server
If you know the amount of data to be received, then you can keep reading from stream until you read all bytes to be received.
your protocol does not inform you the amount to be transfered?
did you make the server too?
or just the client side?
Well I would recomend to define your own message-based protocol on top of TCP in order to differentiate message boundaries.
as said in the stackoverflow post
That way the server can send in a header the amount of data to be transferred
then your client can know when to keep reading from network
since recv doesnt guarantee to receive all data at once
anyone have any preferred libs for parsing custom bit fields? talking like... 7 bit or 10 bit uints, so not aligned cleanly for libs like bitstruct.
naturally can do it manually / roll my own, but i thought perhaps folks had a favorite tool
i spend most of my time in JS so wasnt as familiar
does anyon know if there is a way to build ARP packets without using scapy ?
ping me
@analog umbra
lol
π π
Guys I have an api key but when I use it in the code it is not working...error message says β You must use an api key to authenticate each request...β
I hope this is the right place, is there anyway to check with Python if a certain website is visited?
ping me please
@ember ledge personally, i think flask is better than django for beginners since theres a lot less complexity
and less "magic" going on behind the scenes
also that should've gone in #web-development
p
sku
thanks hmm
Could you be more specific?
Detect the client side traffic?
Or detect that you just went to that website?
I'm working on a project with sockets
in my client file I do:
SERVER_IP="localhost"
SERVER_PORT=9324
with socket.socket(socket.AF_INET,socket.SOCK_STREAM) as s:
s.connect((SERVER_IP,SERVER_PORT))
PORT = 9234
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(("", PORT))
s.listen(5)
print("Program started")
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if data:
print("data:",data)
if not data:
continue
Although I specified a port in both files,
it outputs:
Connected by 127.0.0.1:58128
Why is that??
because a client will use a OS assigned port by default
if you send that client multiple times you'll probably notice that the remote Port will be different every time
yeah
@ember ledge personally, i think flask is better than django for beginners since theres a lot less complexity
@slender steeple ahCool
Is there a way to make this more efficient/without a while True: loop?
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if data:
print("data:",data)
if not data:
continue
just a quick question, is there some sort of a failsafe for the error 10054 (the connection was forcibly closed from the remote host)? I get cut a lot and then the python code stops
you can usepy try: <network activity> except socket.error: print("waaa error")
try:
<network activity>
except socket.error as e:
if e.errno == 10054:
#stuff
else:
raise
ah nice
P2P is a type/category of protocol, not a protocol itself
It is used for protocol that will allow a back and forth connection between one client and one server
hi folks. Any users of the websockets library in here? I'm wondering if it's possible to assign some state to a given websocket connection during the process_request handler?
does anybody know how to send a http request with a proxy using the socket module?
@modest pebble I don't want to burst anyone's bubble, but p2p is serverless
if it is implemented on a server then it is abstracted
p2p is opposite of client server and is client based
servers can act as clients is what you were probably meaning
@analog umbra flask is a bit more flexible, but i think both are equally good. so it all depends on you, what to use.
ok
does any one know how to do network service discovery using zerconf
hi
I'm using requests to download a bunch of images from a text file. Here is my code
image_list = open("images.txt", 'r', encoding="utf8")
for count, line in enumerate(image_list):
split_line = line.split('_')
message_id = split_line[0]
timestamp = split_line[1]
url = ''.join(split_line[3:]).replace('\n', '')
filename = url.split('/')[-1]
output_filename = f"./images/{message_id}_{timestamp}_{filename}"
try:
response = requests.get(url, stream=True)
except Exception:
print(f"Server returned {response.status_code}, skipping image.")
else:
with open(output_filename, "wb") as out_file:
out_file.write(response.content)
out_file.close()
print(f"Downloaded {output_filename}.")```
However, a lot of the images turn out to be 223 or 192 bytes (yes, those specific numbers) and invalid, when they are valid URLs and images such as this one: https://cdn.discordapp.com/attachments/195278167181754369/335246741706244097/CRP838_01-IMS-en_GB.png
However as seen in the screenshot it turns out to be 223 bytes in size for no reason. The script exits with no warnings or errors. What is happening with requests and how can i mitigate this?
And here are more that are 223 bytes
Keep in mind the invalid images only amount to about 1/3rd of all downloaded images, the rest are valid and completely downloaded.
I also don't think this is a problem with large image sizes because this one is about 828kb and there are images that are 6-7MB in size that have downloaded successfully
Also, these are the same images every time I run the script. The exact same images are invalid so that rules out any circumstantial or time-specific server error
Okay, I will try
Btw is using the try except thing good practice? I have not seen any other examples using it and I only use it because I can't seem to catch a 200 outside of it even suing response_code
Oooooh, thank you
:D
Yeah lol
I think it was writing the contents of the errors into the files and assigning the files a mimetype of png/jpg
There are a surprising amount of files that are forbidden access
Is anyone using parallel-ssh to transfer files from one system to another?
Has anyone worked with python and Tor? I need to have a server that receives a small .txt or some bytes, but i dont know if i need ftp, tcp...?
I am lost, and since its a very specific thing, maybe someone could help. Ty