#networks
1 messages · Page 36 of 1
hmmm really it should be using relative URLs to ensure the scheme is the same, and that HTTPs stuff should be handled at the starlette level
nginx doesn't have response rewriting
I just checked forms api which is starlette and it also returns HTTP, in Flask you can overwrite the server name but no idea whether starlette has a similar thing
@cedar forum maybe you could see what happens online?
https://decorator-factory.su/
- log in with github
- create a post
- edit your post
- press save
and watch your Networking tab
I get this
yea i tested with forms-api.pythondiscord.com & can reproduce the 307s
Suppose I have my application reverse proxied, such that http://my.domain/foo (e.g. Traefik or Nginx) has the upstream http://localhost:8000 (the Starlette app). url_for will generate urls relative...
ah
trying to gather where there is some sort of option that has to be set
it pulls it off the host header I think, which internally will be http
if host_header is not None:
url = f"{scheme}://{host_header}{path}"
elif server is None:
url = path
else:
host, port = server
default_port = {"http": 80, "https": 443, "ws": 80, "wss": 443}[scheme]
if port == default_port:
url = f"{scheme}://{host}{path}"
else:
url = f"{scheme}://{host}:{port}{path}"
so not entirely sure how possible that all is without fiddling with internals, I can't see any exposed way to modify this
I guess you could see what Host header nginx is passing on and maybe update that - I don't know what rewrite it applies by default but if you overwrite that to keep a https in maybe it'd accept that
nginx passes the same decorator-factory.su host
The host doesn't contain a scheme
so I might have to put yet another proxy? sounds a bit ridiculous!
AAAAAAaaaaaaa
this... regex...
@cedar forum I fixed it with adding
--proxy-headers --forwarded-allow-ips '*'
``` to uvicorn
The `'*'` is a bit worrying to me... but it doesn't work without it 
@cedar forum am I doing something insecure with the *? Nginx sends requests from all kinds of IPs, like 172.28.0.1 and 172.28.0.4, so I can't just give a list of IPs
hmmmm
that's just docker networks by the looks of it
so yeah
you can't give a list of IPs
well
uh
hm
oh right, I'm stupid, yes
does it accept a CIDR
one sec
yeah it doesn't take a CIDR, otherwise you could explicitly set the docker range, you're fine setting to * providing you've got a configured firewall on the main machine and don't expose ports unnecessarily
👍 np, thanks for letting me know the fix, that'll come in handy
I just edited my backend on the VPS with vim 😎
and I'm going to push to github from there like there's no tomorrow
i want to use W10 and python3 and create a socket to talk to WIFI on a raspi 3B+ to control a servo , theres different datagrams? , tcpip , udp , ??? , what is best to use for gui button , scale , click events
for reliability you should go with tcp
thanks AWKINK
-G
when running idle , i have to be ADMIN , so i can have client / server code run -- im just doing copy paste for now - any help to links to as many example is appreciated
i did a simple protocol for usb - serial to a microcontroller ---- now i want to try a raspi wifi link
socket.socket().recv(abc), is it that abc must be the power of 2?
anyone have any funny server naming conventions I should use for my servers?
um isn't this networking lol, why is this channel so offtopic'd or is batman something related to networking
edit: the original message got remove
no and thats really really not how you should do sockets 😂
thats the equivalent of doing, open("test", "r").read()
you dont close it or manage it or anything
I am getting an error when I try to send data to my robot which is on another device on the same network through sockets from my Django Site, it is saying that ConnectionRefusedError at /robot/1, [Errno 111] Connection refused. If anybody knows what is causing this help would be great.
Full Code:
https://stackoverflow.com/questions/69238585/django-sockets-connectionrefusederror-at-robot-1-errno-111-connection-refus
this looks like a CAPTCHA bypass, this breaks rule 5
on top of that, this isnt python and the error your getting doesnt relate to networking
This is PHP
if anybody could help me with a simple sockets question then please go to #help-cookie thanks
when using pretty much any request lib in python, I am triggering this sites cloudflare. I tried using cloudscraper and cfscraper, always getting a 403. does anyone have a workaround or any ideas?
Hey guys do u know of any alternatives for ngrok which works with both tcp and udp which is free. I heard abt portmap but i am unable to use it with ubuntu 20 on my raspberry pi 4b arm64 ed.
can someone help me with this error i am getting while trying to create an smtp connection
please help fast
smtplib.SMTP('smtp.gmail.com',587)
thanks a lot @light zealot
😄
!close
Lol, this is not help channel
He just a good people who always remember to close after get help


What if I want to do this for Yahoo or other server?
👍
threading.Thread objects have a name property which you can just reassign to any other string
I dont know if thats the name that vsc uses on the debugger tool though
a socket.socket() call does not return a new thread
just a socket instance
how many clients did you have open?
Can anyone here recommend a Python library for interacting with the Open Graph protocol? I'm using Python 3.
opengraph is just html tags, do you mean parse them from a page @thorny patio ?
hi can i ask question regarding DVR here
https://en.wikipedia.org/wiki/Distance-vector_routing_protocol ? you can ask away but it does sound like a very niche topic, so chance of someone else knowing about it are rather slim :(
A distance-vector routing protocol in data networks determines the best route for data packets based on distance. Distance-vector routing protocols measure the distance by the number of routers a packet has to pass, one router counts as one hop. Some distance-vector protocols also take into account network latency and other factors that influenc...
Perhaps that will be good enough. So yes, I'd try that.
i need to transfer files with raw bytes over a text based protocol. Im currently using base64 to do it but it adds too much extra data (~33% increase). Whats the best way to transfer raw bytes over a text based protocol while minimizing network usage and preferably minimizing resources used to process the files into a text friendly form?
According to https://en.wikipedia.org/wiki/Binary-to-text_encoding, there are only a few standards more efficient than base64. You could try base85 (25% increase) or yEnc(apparently only a 2% increase?), though you'll have to test how much encoding/decoding overhead each of them add.
it looks like there even exists an obscure Python yEnc library written in C: https://github.com/sabnzbd/sabyenc
yenc isnt foolproof so i cant use it, base85 sounds like my best bet but a 25% increase is still kinda scuffed. guess theres no free lunch for text based file transfer
Why is it then when two sockets from different networks are connected, only the network with the server in it needs to configure port forwarding?
The client will send something to the router on a specific port whic is then forward to the server,
but the server can just send back to the client without that network having port forwarding. Wouldn't the router also have to forward that to the client?
because the server is on the private network. The public hosts will need to connect to your router transparently as if they were directly connecting to you locally. Read up on network address translation to figure out how it works
Hey fellas, some jackass just tried Dossing me without hiding himself.
Interesting time it is reporting someone to the FBI isn't it.
lmao DOS
😎
Port forwarding, that's a thing that simple don't get
Private network you mean interior IP address?
Wait, they connect "invisible" as part of my LAN?
okay so I'm trying to make my computer talk to another computer using socket, right now its working, but I'm still only using my computer to talk to myself, if it works using it like this, is it safe to say that it'll work between two different computers with different ips?
if you have two computers on the same LAN, then that's a pretty safe 'yes'. but when you introduce the Internet, NAT, and firewalls there's more to consider.
okay, do you have any tips for when I get to that point? as I do intend to have one computer constantly listening for request, its going to act as a datastore of sorts
if you want to grab a help channel and chat I am available
i'm kinda new to this discord server, how do "grab" a help channel?
unless you want to type it all out here. I don't think this channel is as active
idk, im fine with that if you are
so what's the project
mainly just make my own database, so I have a class that has a dictionary that acts as the datastore for now, it also has a socket.accept() to listen for functions sent to it. I want to be able to send a request to this computer with some data, and it will add it to the data store, so far I have that made and it works, I'm more of concerned about the fact that I don't know if ill be able to send request to it when I'm on a different computer that doesn't use the same network
right now the code just uses my ipv4, well thats the one i copy and pasted from command prompt when i did ipconfig
so are you sending between two physical computers on the same network right now, or just connecting from one comp to itself?
"or just connecting from one comp to itself?" this
i don't have to physical computers running windows 10 at my disposal to test right now
just for context, is this just a testing thing or is there a specific use case/application surrounding this?
should i just send the code that i have right now?
sure
import os, socket, json
class DataBase():
def __init__(self,HostingIp: str, HostingPort: int):
self.Ip = HostingIp
self.Port = HostingPort
self.db = {}
self.Boot()
#Boot up server function
def Boot(self):
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind((self.Ip,self.Port))
s.listen()
while 1==1 and input().lower()[0] != 'k':
print('Waiting for conection...')
conn, addr = s.accept()
data = conn.recv(1024)
#Return data in local DataBase
def returnData(x):
return json.dumps(self.db).encode('UTF-8')
#Return info about the database (port, ip, etc when i make it more in depth)
def returnInfo(x):
return json.dumps({'IP': self.Ip,'Port': self.Port}).encode('UTF-8')
#Just lists the functions in the db
def DbHelp(x):
return b', '.join(funcs.keys())
funcs = {
b'getData': returnData,
b'DbInfo': returnInfo,
b'DbCommands': DbHelp
}
#try and send the function return value, if its not a function or an error occours just return invalid
try:
conn.sendall(bytes(funcs[data](0)))
except:
conn.sendall(b'Invalid function')
def changeDb(self,Key: str or int, Value: str or int or bool) -> None:
self.db[Key] = Value```
here the database code
import Database as db
#Create database, this is ran off the computer that you create this with
db = db.DataBase('10.0.0.10', 4032 )```
and heres the code to make a database
what is your goal with this code
just to clarify why I ask, if you're trying to send traffic over the Internet, it usually makes sense to use a protocol normally used on the Internet, such as HTTP.
just make a database class that when created makes a database that can be connected to and used for datastoring
is this just a "learning" project? is the data you're sending coming from another application and/or going to be further processed?
more of just learning, i'm just getting into networking and though something like this would be a good starter project
and i may further process it, i guess a good way to describe this is more of just a way to send data to a off local place for storing
so if you had two computers in front of you on the same private network could probably just connect to the port on the listening side and send the data with your sending side script. if you were trying to do this over the Internet, you would need a static IP or dynamic DNS entry and a port forwarding rule on the router that serves that private network.
mmm, okay, is there anyway i could use on of the computers to host a static ip? or would that need to be done on a router thats config allows that
because im still in hs, so i don't really wanna be messing with my family's router lol
what kind of computer do you have? if you're just trying to learn things I would suggest using virtual machines
its just like a office computer, no graphics card
you would be able to set up different virtual computers/networks in your own sandbox
well what's it have for memory and available storage
2 tb of storage and 8gb of memory, i dont really think it's enough
i have a better computer at my dads house that has the same amount of memory but its probably faster, less available storage
well it may be more effort than it's worth, but you would see what I think you're trying to next: 2 IPs talking to each other
someone can help me? i'm trying different ways to listen the connection between a game server and the client
import _thread
import time
import socket
data = ''
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('', 51259))
# Define a function for the thread
def listening_thread():
global data
while True:
data_raw, addr = sock.recvfrom(1024)
data = data_raw.decode()
print ("Received message inside thread:", data)
try:
_thread.start_new_thread(listening_thread, ())
except:
print("Error: unable to start thread")
quit()
while True:
print('Now I can do something useful while waiting in the main body.')
if data:
print('THE PACKET RECEIVED BY THE MAIN BODY IS: ' + data)
data = ''
time.sleep(2)
i tried different ways to listen and get the data, but nothing works
i know the dest ip and it can have differents ports
dest/source i'm looking for: 5.188.125.31
what u mean?
this code I think is the server not? and the client? are both in the same machine?
i dont think they are the same, the ip of the server is 5.188.125.31 and i know the source and dest port too
i tried
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('', 5056))
while True:
data, addr = s.recv(1024)
if data:
print(f'data received: {data.decode("utf-8")}')
else:
print('a')
but it dont even connect to try the prints on the bottom part
If you put '' as the ip, then the server won't be visible from outside your machine
idk what u mean
i'm thinking about to try another language to get the UDP packages data
Is the client running on a different device than the server?
ye, the server is from a enterprise, is not mine
Hey, I was trying to send emails using smtp through socks5 proxy. Weird thing is sometimes simple emails like "what's up or how are you?" lands in spam. But if i send it gmail from browser using the same proxy it goes to inbox. I am not sure what is happening or what is causing this type of behavior.
how do i show two way communication on a website ?
im trying to simulate payment gateway system so i wanna send info from payment gateway to "bank".
something similar to socket programming i guess
Rather localhost 
headers = {"Authorization": f"Bot {TOKEN}"}
path = f"/channels/{channel_id}/messages"
url = BASE + path
params = {
"after": after_id,
"before": before_id,
"around": around_id,
"limit": limit
}
response = httpx.get(url, params=params, headers=headers)
return response.json()
Why does httpx.get(...) cause an error but requests.get(...) works as expcted
Anyone knows any python script that generates the arp table using snmp?
Hi everyone I want to learn a bit more about networking specifically so that I can make games with either clients/server, peer to peer or player hosted lobbies
can anyone link me to some good resources for where to learn how to do this and also how I can host it securely
btw I would also want to learn how to do this through both udp and tcp/ip since which one is better would depend on the game
Hey! So I've been trying to make a server with 2 clients but I don't know how this is what my code currently looks like with what I added to try add another client
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serverSocket.bind(("127.0.0.1",8080))
serverSocket.listen()
while(True):
(clientConnected, clientAddress) = serverSocket.accept()
(clientaltConnected, clientaltAddress) = serverSocket.accept()
print("Accepted a connection request from %s:%s"%(clientAddress[0], clientAddress[1]))
print("Accepted a connection request from %s:%s"%(clientaltAddress[0], clientaltAddress[1]))
while True:
dataFromClient = clientConnected.recv(1024)
print(dataFromClient.decode())
while True:
dataFromClientalt = clientaltConnected.recv(1024)
print(dataFromClientalt.decode())
while True:
dataserver = input("")
clientConnected.send(dataserver.encode())
clientConnected.send("Client Connected!".encode())
clientaltConnected.send("Client Connected!".encode())```
okay, i dont mean to offend but this is implemented poorly
for instance, you have 3 while True loops in a row however the code will never exit the first while loop meaning any code after it wont run
solution: you could start a new thread to handle each client as they connect?
also the serverSocket.listen() function should require an integer argument specifying client backlog count
at least in python 3.9 it does
hey guys
i needed help in regarding laravel is this the best place to ask?
i ran theese jwt codes in my laravel but now the app is not working as i click a button only white shows shows..these were the JWT commands
php artisan jwt:secret
php artisan optimize
php artisan clear-compiled
Hello good people, I have recently release a package called Zero. With Zero you can build services in minutes! I am open to have discussion on this too. Let me know your thoughts. Have a look - https://github.com/Ananto30/zero
Hello! Im kind of desperate so I'll ask here. Im trying to create an app to connect two pcs (both users know IPs and Port beforehand) and im trying to avoid making the users forward ports. Is there any way on python to stablish a direct connection between two PCs without making the users manually forward the port?? I've seen things like UPnP and hole punching but It's been imposible for me to see explanations that actually manage to do it without forwarding a port. I've also looked into trying to make some sort of connection like the one made by zerotier or hamachi but I didn't get useful results. Does anyone know any way?
try ngrok
This actually looks very promising. Thank you very much! (Still just in case, if anyone else knows of other ways please tell them)
but one disadvantage with ngrok
is that if u use free plan then u might get randomized big ip
I was looking into just make it over http and use port 80 but idk how that works
Or even if you can actually do that
creat a ngrok account
get the token download the suitable client
and run and pass the token
then use cli command
Will the app depend on ngroks service? The idea behind the app is to make it as a decentralized p2p network independent of any external service
need too open http port
ngrok http 8080
hm wdym?
I want to stablish a direct connection without having to use any server as mediator
Just the two pcs and well, the internet
tcp mode is also there with ngrok
What I mean is does using ngrok mean the app will be making use of external servers provided by ngrok or whoever runs the service
then u might do port forwarding etc etc same thing_with both pc
thats bit shit process
instead u can make a intermediate server and make the clients to connet to it
Then a server has to be supported, which is what im trying to avoid
Im guessing it's too weird. I'll have to settle with having the people open a specific port
hmm now this Kind idea is really hard to implement
this is the only way for clients to connect easily without any client side configs
that sucks man
no one will prefer to use ur app if u ask ur users to port forward in their pc
I mean, there are a lot of apps that do it
yea ik omegle uses this kinda
similar idea to this would it be easy to make an app where the server is just used to let players make and connect to lobbies?
the lobbies would be user hosted
hmmm kinda data loss may happen
..if this
ok gtg
be back in 10mins
Wait, outrageous idea
The whole thing about ports is because of NAT right, which is a whacky horrible patch made to solve the lack of ipv4 addresses
Is it possible to just stablish the connection through ipv6?
Is that a thing already?
I think my best bet is to try to use UPnP right now
But that completely defeats the purpose
btw for what your trying to do doesnt hamachi just work?
Kind of? But hamachi uses external servers to work, which is my idea
Im not really doing this for a very specific intention, it's mainly academic purposes
Im doing this to learn and probably as a part of my capstone project
^^ do let me know if you figure it out since I also want to do something similar
Sure! A friend and I have gotten across this
https://github.com/povilasb/pyigd
It's the best lead we have for now, but we haven't used it and tested it yet
Part 2 is here for UDP p2p connections. In the first video I used netcat, in this video I'll use Python instead and streamline the connection process using a rendezvous server.
Hope you enjoyed the video!
Part 1: https://youtu.be/TiMeoQt3K4g
Check out this code here:
https://github.com/engineer-man/youtube-code/tree/master/141
Join my Discor...
have a look at this in your case you wouldn't need the server since its only used to get the ip addresses
although I'm not sure if this is secure or works with a firewall
actually seems this should work regardless of firewall but the connection will close after ~30 secs since the last message was sent
so you would need to constantly send messages to keep the connection open
@crude ridge
if you cant find a way to make it work with TCP I think you could emulate TCP with UDP and it will be fine
but you will end up having to write a lot more code
@mellow knot This framework is good, I managed to use UPnP properly with it in the end
https://upnpy.readthedocs.io/en/latest/Introduction/
nice
Where can I upload a file so that when I open the link it will download immediately without pressing anything?
please
Basically if you request some link one of the response headers should be
Content-Disposition: attachment
then the file will be downloaded
Hey I have an ec2 instance and I installed xampp and now I am able to access it using it's IP on port 80, however I want to connect to mysql using python which I am not able to, can anyone help me on this?
Python script won’t be running on the localhost, I want to run it remotely
How can I access mysql hosted using xampp on aws from python? I can access xampp using AWS public IP
Can I keep an https socket in perpetual connection?
Sounds like a job for - https://github.com/codemation/easyrpc
Are hosts separated by the internet or local network?
Separate
Two choices then with easyrpc, 1) have one host which has the forwarding, both hosts running EasyRpcServers, have the un forwarded host create a server-proxy connect to forwarded host, then your channel is available for biderectional rpc …. Or 2) create a third party external host which also runs an EasyRpcServer and have each host create server proxies to this third host on the same namespace which enables the same channel of communication, check the docs for a more visual representation
In the end there's no way to scape the port forwarding curse
Thanks a lot for the help
#!/usr/bin/env python
# WS server that sends messages at random intervals
import asyncio
import datetime
import random
import websockets
async def time(websocket, path):
while True:
now = datetime.datetime.utcnow().isoformat() + "Z"
await websocket.send(now)
await asyncio.sleep(random.random() * 3)
async def main():
async with websockets.serve(time, "localhost", 5678):
await asyncio.Future() # run forever
asyncio.run(main())
im going through the websockets getting started and am wondering how I can get this hosted on a server
I have a linode running rn and tried changing the localhost to the servers ip and did the same for the client but its not working
ohh actually nvm it works now turns out when changing the clients IP I have to specify the port as well but I deleted it when changing ips from localhost and didnt realise
Hey everyone !
I'm having an issue while requesting a lot of urls with aiohttp
I've created a class which I initialize with a semaphore and a max concurrent processes amount
then i call a method fetch_url which is basically doing this :
async def fetch_url(self, url):
async with self.semaphore:
async with (await self.get_session()).get(
url, ssl=ssl.SSLContext()
) as response:
response.raise_for_status()
return await response.read()
(simplified without error and retries management)
then i call this a bunch of times within an asyncio.gather
and it works for some time but then i get that error :
[ERROR] 12:41:59 : Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x000002450EECFC10>
transport: <_ProactorSocketTransport fd=2216 read=<_OverlappedFuture cancelled>>
I've read online that this might be due to a CPU or RAM overload, but is it really the case ? and how could i fix that ?
(It works fine with requests so i guess it doesn't come from the websites i request, i just wanted to make it better with aiohttp)
Thanks for the help and don't hesitate to tell me if you need more infos or if this question is not suitable in this channel (i wasn't sure)
Does anyone know where to start learning pybluez, I am a little bit lost.
Hello
hi where do U se the tryhackme token here?
anyone have experience with socket using python?
only experience with struggling lol
lmao damn
Hey... So i am using a wpa2 enabled wifi and my neighbour above(a kid) who is learning cybersec... He knows what i am doing realated to the internet... Does this mean he knows the WiFi password? ping me back
Hi, I was told to ask here, but since this is a Python discord, is it allowed to ask questions about Wireshark? I will use python with it, but right know I'm having issues identifying video streams packets, so it might be way off-topic.
Hi everyone I've built a webapp that communicates with a python backend using websockets, I'm trying to host the frontend on github and the backend on a linode rn but it wont work unless I use wss instead of ws but I dont know how to get an ssl certificate for my server can someone help?
if possible I would like to know of a free or at least the cheapest way to get this working since its just a learning project
Let's Encrypt offers free SSL certificates
You can also create your own certificate
Go ahead!
sry to bother you about this but you could you help me out with how to do this for my case since I'm not getting the certificate for the website but for the websocket server
not sure what options I should be picking here https://certbot.eff.org/instructions
I have a website https://www.foo.com and on this site I connect to other machines with a websocket (some random ip address of a machine that has our software running on it). i.e. I connect to a web...
btw this SO has pretty much the same problem as me and I think it explains the issue a bit better
Can you describe your server?
https://websockets.readthedocs.io/en/stable/intro/index.html I built it by following the browser based example here
Requirements: websockets requires Python ≥ 3.7. Installation: Install websockets with: pip install websockets Basic example: Here’s a WebSocket server example. It reads a name from the client, send...
So you are using plain Python server without any proxy like NGINX?
I think that you should check Software as None of the above and System as pip 
Never used this configuration, I am running every server behind NGINX
thx will give it a try
btw should I have the server running while doing this?
You don't need to stop it as far as I see
its asking about which domain names I want on the certificate what should I put here?
just the server ip?
Don't you have a domain?
Try to put IP
no domain just using the ip address with a specific port
should i put just the ip like this
176.58.109.37
or should I include the port aswell
176.58.109.37:6789
Just IP, certs don't refer to ports
However I am not sure that this will work 
yeah it doesnt 😦
so I need to get a domain name as well...
I thought the domain name was kind of just a redirect though to make your ip look nicer for users
You can generate your own cert
would that work with github pages?#
I remember reading something about it not working all the time
I am afraid that nope
GitHub provides own certs iirc
im a bit confused as to what I need to do now lol
do you have any suggestions for what I should try doing to get this working?
You need to generate your own self-signed certificate https://stackoverflow.com/a/10176685
but this still wouldnt allow me to connect to my frontend on github no?
Speaking honestly I don't really understand the core of your problem 
You have frontend on GitHub Pages and backend somewhere else. Do you can to connect frontend with backkend or what? 
I have a website https://www.foo.com and on this site I connect to other machines with a websocket (some random ip address of a machine that has our software running on it). i.e. I connect to a web...
have a look at this its the same problem pretty much
I am having an issue with my django site running on a heroku server where when I try to connect to a socket running on a raspberry pi, it just "spins" for ~20 secs and then times out telling me to check the logs. Logs are attached, I think I have to change the server but I am unsure of what to change it to. Any help would be great.
(PLEASE PING IF REPLYING 🙂 )
https://imgur.com/a/op15OXb
Okay, give me a second
@mellow knot you have the solution 🙂 like I said, generate self-signed certificate
hmm will try but ideally i wouldnt want a warning
Ah thank you 😎 Currently in the angular app, I am specifying the IP address of the websocket server. Ok, that sounds promising then. I’m confused here… The client is a web app (Angular single page application) hosted on a GoDaddy webserver. The DNS settings for the scoutgames.online domain point to this webserver and therefore pages are ...
found this as well solution seemed to be to get a domain name for the server
issue is not sure how I can connect that domain name to my server got one from lCN but they pretty much just let me use their website builder to connect the domain name
not sure if im missing something or theyre just trying to lock me in to their services
you can’t get SSL certs for IPs (well, I think you can with someone like Digicert, but they are pricey)
I don’t know what ICN is but you might be able to amend DNS to assign a subdomain to the server (e.g. api.mysite.com)
if you can do that, you can use certbot or acme.sh to provision a free certificate from Let’s Encrypt
Well, I can't get to filter out the TCP packages that do contain parts of a streaming video.
Some of the transport protocols for streaming that I've found are RTP/HTTPStream/RTSP. But I'm struggling a lot trying to differ all the other noise. There might be more according to which protocol it uses and it might have another name if it's encrypted.
Is it possible to get the information on the host easily with a well made wireshark filter or such?
like this?
I put the servers ip in results
this is the domain name
websockettictactoe.co.uk
put api in the host name field, set the TTL to 300
so would I use it by doing
websockettictactoe.co.uk/api
what does the ttl do?
no, it'd be api.websockettictactoe.co.uk
time to live, it tells computers how long they should hold onto that record before checking it again
300 is 300 seconds which is 5 minutes
I need to make calls to this api very frequently so maybe once every second at least
no, that's not what TTL is for
unrelated things
I'd put 300 in there, it's just pretty standard
ahh ok thats good then
how come they put 86400 then?
if its not something that should change anyway wouldnt a longer time be better?
that's 1 day, it's up to you, but while setting up at least it's nice to have a short TTL in case a mistake is made
btw there shouldnt be any issues if I put the path to my cert and key in the server file on github right?
cert = "path to cert"
key = "path to key"
ssl_context.load_cert_chain(cert, keyfile=key)
like that
no issues with the path, but don't put the contents there obviously
I have the certificate now and the servers running but it fails to connect
let websocket = new WebSocket(`wss://${DOMAIN}:${PORT}`);
thats what I have on the client
before adding the cert it was working with ws with the cert it doesnt work with either wss or ws
@cedar forum do you know what other info I might have to include to get it working?
thats the error message
finally got it working 🎊
turns out the issue was becasue I was doing api.websockettictactoe.co.uk
change it to websockettictactoe.co.uk
and it works
I'm assuming this is becasue I didnt add the api.websockettictactoe.co.uk
when I was making the certificate
thanks so much for the help
@cedar forum
@clear bobcat
Anyone knows how to fix this
Just learn basic networking principles and you should be good.
But where to learn it from?
TIP JAR: https://www.paypal.me/PowerCert
My CompTIA Network+ eBook is now available ►►http://powercert.com/comptianetworkebook.html
Get the VPN that I use (affiliate). https://nordvpn.com/powercert
For 66% off a 2-year plan + 1 month free.
My YouTube Setup
https://www.amazon.com/gp/registry/wishlist/I0ZAXJ8GKJX4/ref=cm_wl_list_o_1?&_encoding...
Just skip the hardware parts of this course.
Cables, connectors, wiring etc.
Does anyone control ad through Python instead of powershell?
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
ok
from netmiko, bar= net_connect.send_command('show bgp peer-template foo'). What do you guys recommend how i should parse through the output?
Anyone got any idea on why this port forwarding isn't working?
I've port forwarded before, I know how but for some reason this isn't working
I've also checked on 2 port checking sites, nothing
thanks so much ma
so my neigbour tried using fluxion on me to get my wifi password but failed... Is there any other method for me to hack his password for payback? Ping me pls.. I know its not really ethical, but he started this...
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
!rule 0
:x: Invalid rule indices: 0
Illegal
Hey, I want to setup a livefeed from a camera I have on my computer to another computer (over 4G/5G) with the least delay possible. Should I use the socket or the websocket library? I'm not sure what's the difference exactly.
Edit: I'm dumb asf I forgot to set the host in the flask site.
Can someone explain to me what is cname with an example, i have looked around sites and videos but i havent quite understand what it is
I would use sockets, unless you're using sending the data to a website or some place where socket is not sutable. It is generally faster than websockets and is preferred where performance is a priority
you can kind of just think it of as an alias, where the left-hand label is an alias for the right-hand value. Example; bar.example.com CNAME foo.example.com , here bar.example.com is an alias for foo.example.com, on a request to bar.example.com the canonical name will be returned (cname), in this case: foo.example.com
If i understood correctly it means parked sites like kbank.top have millions of cname because when we put random value to left hand label which is subdomain we get to the same website again again
right?
not necessarily. Depending on how the server is set-up you can redirect all subdomains to another part of the domain
I didnt understand so if i want to redirect all subdomains i can do it without cname but if i want to direct my site with specific subdomains i do it with cname. is it correct?
cname is normally used to point a domain to some other domain.
not necessarily only subdomains
Oh now i see, thank you so much for helping
Im not sure if im right here but i'm using selenium and after i launch, it opens site and instantly closes. Any support?
How can I rewrite this in python?
const wordEle = document.querySelector("#word");
const phonetics = document.querySelector(".phonetics");
const wordMeaning = document.querySelector(".word-definition");
const handle = async (e) => {
if (e.keyCode === 13) {
const word = e.target.value;
const result = await fetch(
`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`
);
const data = await result.json();
resultDiv.style.display = "block";
if (result.ok) {
wordEle.innerText = data[0].word;
phonetics.innerText = data[0].phonetics[0].text;
audio.src = data[0].phonetics[0].audio;
wordMeaning.innerText = data[0].meanings[0].definitions[0].definition;
const synonyms = data[0].meanings[0].definitions[0].synonyms;
let synonymsData = "";
for (let i = 0; i < synonyms.length; i++) {
synonymsData += `<p class="pills">${synonyms[i]}<p>`;
}
document.querySelector(".synonyms").innerHTML = synonymsData;
return;
} else {
document.querySelectorAll(".meaningheading")[0].style.display = "none";
document.querySelectorAll(".meaningheading")[1].style.display = "none";
wordEle.innerText = data.title;
wordMeaning.innerText = data.message;
}
}
};```
you cant afaik, it uses javascript things like queryselector
I want to build a dictionary, but I don't know how to make data base in js, and for this I want to rewrite this app
#help-cake please 🙏
Sleep or input after you launch
hey, im trying to decode a tcp packet, so i can resend the package in python, but i think it is decoded: ... .. .play_fab_title_id... .74a2b... .. .auction_sell_locked....... .. .auction_buy_locked...... .a. . .c. .³xœ¥XÉŽ.E.®Y
does someone know how i could get the valuable data out of it and remove/decode the dots and other weird characters?
how do I use the youtube API
with python
to make a youtube video one like higher
so how do I do it?
hmm that seems like it breaks ToS 😖
told him that already lol but he just wants to know how to use the youtube api apparently
to make a youtube video one like higher
not how the API is meant to be used, and breaks ToS im pretty sure
should also mention you probably cant use the youtube api for this
since I highly doubt that would be part of the api
if your goal is to increase video likes/subscribes then you should stop now
as for the youtube api, check this out https://developers.google.com/youtube/v3/docs/
one higher = queue next probably
"one like higher" tho 😕
How essential is understanding the 7-layers of networking for run of the mill web development?
(i.e tcp/ip layer, application layer, hardware layer)
it’s good to have an understanding of how a web request gets from Client to Server, you don’t need a huge understanding of the ins and outs of every protocol in the stack
I’d say anything below TCP/IP isn’t super important though for basic web dev stuff
Excellent. Thanks Joe
like you don’t need to know Ethernet frames/physical link and whatnot
but an understanding of HTTP, TCP, UDP and IP are all handy to have, and if you want TLS is also handy to know
Wonderful, thanks again for the information
no problem! happy to explain any questions about any of those protocols or other bits of the OSI model if asked here 😄
also, if you want to see a more… realistic application of network layers I recommend looking up the “DoD model”
it’s a condensed version of the OSI model which in my opinion at least ties more to actual applications, or at least better organises things
so with that model it’s good to have an idea of application, host to host and internet, anything else for your standard backend web dev should be optional
I need help w/ websockets 🙂 #help-broccoli
Requirements: websockets requires Python ≥ 3.7. Installation: Install websockets with: pip install websockets Basic example: Here’s a WebSocket server example. It reads a name from the client, send...
have a look at this I ended using the Synchronization example as a base for my application its fairly east to understand if you follow the examples
havent used rust before though but I think the python server will look the same regardless of client
since https://github.com/amogorkon/justuse is getting more and more stable, it's time to look into possible approaches for my quest on a P2P package repo again
last time i checked, cockroachdb and InterPlanetary File System were possible candidates
anyone interested in revolutionizing the package story in python by helping me with a prototype? 😉
good ideas are also appreciated
Hey guys. I'm having some issues with Wireshark. Can someone give me a hand? I'm not quite certain that I'm properly setting up the capture or filtering correctly.
can anyone help me with selenium in dm?
All these questions and barely any answers *cries in existencialism
Try this
import os
import socket
import multiprocessing
import subprocess
import os
def pinger(job_q, results_q):
"""
Do Ping
:param job_q:
:param results_q:
:return:
"""
DEVNULL = open(os.devnull, 'w')
while True:
ip = job_q.get()
if ip is None:
break
try:
subprocess.check_call(['ping', '-c1', ip],
stdout=DEVNULL)
results_q.put(ip)
except:
pass
def get_my_ip():
"""
Find my IP address
:return:
"""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
return ip
def map_network(pool_size=255):
"""
Maps the network
:param pool_size: amount of parallel ping processes
:return: list of valid ip addresses
"""
ip_list = list()
# get my IP and compose a base like 192.168.1.xxx
ip_parts = get_my_ip().split('.')
base_ip = ip_parts[0] + '.' + ip_parts[1] + '.' + ip_parts[2] + '.'
# prepare the jobs queue
jobs = multiprocessing.Queue()
results = multiprocessing.Queue()
pool = [multiprocessing.Process(target=pinger, args=(jobs, results)) for i in range(pool_size)]
for p in pool:
p.start()
# cue hte ping processes
for i in range(1, 255):
jobs.put(base_ip + '{0}'.format(i))
for p in pool:
jobs.put(None)
for p in pool:
p.join()
# collect he results
while not results.empty():
ip = results.get()
ip_list.append(ip)
return ip_list
if name == 'main':
print('Mapping...')
lst = map_network()
print(lst)
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
What would be you guys recommendation for parsing multi lines out put from a netmiko net_connect.send_command("show version")?
Hey everyone 👋 . I have started learning about networking and I'm confused ( a lot!).
- what is the difference between web servers and browser?
-I understand that interaction between 2 things needs a protocol to specify how the conversation well be. Telnet is a protocol?
3- what is sockets? and why it's differ from a browser?
Does anyone have an example of two python scripts communicating via websockets?
Hi Guy's !!
This is my first You Tube Video !!
Hope you guy's like it !!
Enjoy the video !!
Don't Forget to Like , Share & Subscribe !!
Thank You
My Social :-
Discord
https://discord.com/invite/ZNmPdxxW3F
Reddit -
https://www.reddit.com/user/Mr_Gill_16/
Twitch -
https://www.twitch.tv/mr_chill_16
#venge_op
#venge.io
Like, making a browser and a web server script?
Would anyone want to work together on a python project through GitHib? I know the basics of python and am familiar with some of the common modules used and would like to gain more experience by coding more projects. I don't really care what the program would be, however I would like for it to be challenging.
If anyone would be interesting in doing so DM me or just respond to the message.
That's what I don't understand, I just want to share variable between two scrips running on two different computers, but I don't know if I can use websockets for that
you can use websockets to share data between two clients, thats its purpose
yes, if you know a domain you can always get the ip address, because computers communicate only using ips, so domains have to get resolved to that eventually
i started learning about sockets and stuff just today
# this is my first server!
from socket import *
def createServer():
serversocket = socket(AF_INET, SOCK_STREAM)
try:
serversocket.bind(('localhost' , 9000))
serversocket.listen(5)
while(1):
(clientsocket, address) = serversocket.accept()
read_data = clientsocket.recv(5000).decode()
pieces = read_data.split("\n")
if ( len(pieces) > 0 ) : print(pieces[0])
data = "HTTP/1.1 200 OK\r\n"
data += "Content-Type: text/html; charest = utf-8\r\n"
data += "\r\n"
data += "<html><body>this is my first time doing this lol, no body cares anyway!. </body></html>\r\n\r\n"
clientsocket.sendall(data.encode())
clientsocket.shutdown(SHUT_WR)
except KeyboardInterrupt :
print("\nShutting down ...\n");
except Exception as exc:
print("Error:\n");
print(exc)
serversocket.close()
print('Access http://localhost:9000')
createServer()
i get an error if i change the "localhost" to something else, why?
this is a simple server, ( i didn't build it, just following a tutorial).
- is it okey if i choose any port?
nonsense words like "idkdskj"
what did you expect it to do ?
"localhost" simply refers to your own computer, and the port is a number in which the client attempts to connect to (checks if its a process running on that port)
"localhost" could be replaced with any ipaddress (also domain name) and your script (the client) would try to connect to it. "idksdj" is not a valid domain name thus it wont work
now i understand. Thank you 🙏
You would want to use raw sockets for something that basic
This is a HTTP server, are you sure that's want your looking for
As for an error if it's not localhost, your hosting it yourself right on the same computer so you need to bind it to localhost
Well I want to stream a video over internet as well
maybe look into websockets and webrtc
Hi guys, does fake_useragent work well?
I was just learning about the header portion of requests library and I wanted to see how I can make sure I am more private
You might want to try in #async-and-concurrency
Ha, alright
Try not to fake it, but you don't need to provide anything for that header
Aka you can omit it without consequence
As the client, the only header you need for HTTP1.1+ is the host header
https://discord.com/api/v9/channels/{gcID}/call/ring
why does a post request to this not work
Does anyone know good ansible courses?
gcID = input("id: ")
Please don’t advertise this here
For the sake of intuition, can I think of a pair of streams as two guys, each with an open end of a pipe that leads to a tap at the other guy?
What I mean is:
if I pour some water in my open end, I wont see the water level drop until the other guy opens the tap on his side?
And the only way for me to tell if the other guy sent me some water, is to open my tap and see if anything comes out?
I guess what I'm trying to wrap my head around here is the whole flush/drain thing (do I see the water level drop). Receiving is blocking (or awaited) and you're just sort of blindly attempting to get some water, while sending doesn't have to be. You can just pour some water, but you have the option to wait for the pipe to become empty first?
if I open my tap, just for long enough to fill a bucket with 1024 units of water, any water still in the pipe will stay there, and be the first to come out whenever I open my tap again?
Well, what exactly do you mean? by messenger, do you just mean chat?
And what kind of help are you looking for? do you just want to know which concepts apply, or what to read up on?
Chat with usernames no accounts
Usernames, no account? so like connecting as a guest basically? you just pick a name when you connect?
And for the most part network is network.
There's a few security aspects that come into play on WAN, but it's pretty much the same
again what kind of help are you looking for here? I'm slowly getting the sense that you are looking for a step by step guide, for the complete thing. If that's the case, you might want to start out a bit smaller.
You could play around with sockets a bit, and just see if you can have two processes send messages to each other. Then you can try to build a simple protocol or communication flow
And if you want it to work outside of your local network, you need to either forward some ports, or have a common server hosted somewhere
oh no i have experience with python
i have been programing for 6 years?
...
hard keeping track
Right. I'm not saying you're not capable as programmer. It's just that judging by your understanding of networking, you may want to start with just that.
Take a little detour and get an understanding of the basic communication first. Once you've played around with that a bit, return to the messenger project.
Otherwise, I assure you that this will end with you copy/pasting a bunch of code that you don't understand, in which case you might as well just download an existing app
yeah you're correct with your analogy, but if you think of the water as data you will not always lose the 'water' if you pour it, as the guy which is sending could still keep the data which he is sending
ok
Does anyone know if it’s possible to create a CNAME record to replace the given azure’s IP?
yo
yo
@latent sage yo
hello
Can someone please tell me the hex values assigned to these TLS cipher suites TLS_AES_128_GCM_SHA256 TLS_AES_256_GCM_SHA384 TLS_CHACHA20_POLY1305_SHA256
i know this is 2 months old but im kinda doing a similar thing but you can use netmiko for this and it makes it 100x easier lol
import netmiko
device = {
"device_type": "cisco_ios_serial",
# "username": "",
# "password": "",
"serial_settings": {"port": "COM3"},
"session_log": "my_output.txt",
'global_delay_factor':4}
conn = netmiko.ConnectHandler(**device)
conn.enable()
print(conn.send_command('sh inv'))
print(conn.send_command('sh env all'))
print(conn.send_command('sh post'))
print(conn.send_command('sh ver'))
print(conn.send_command('dir'))
print(conn.send_command('sh startup-config'))
print(conn.send_command('show vlan'))
print(conn.send_command('show ip int brief'))
conn.disconnect()
im glad im not the only person in the world trying to do networking automation stuff over serial in 2021
anyone good with sockets in python?
What is a socket?
If you guys have any experience working with sockets and ngrok, I have an interesting problem I have not been able to solve combining django with sockets for networking between server and raspberrypi. Full question: https://stackoverflow.com/questions/69503197/ngrok-with-python-and-raspberry-pi
I actually switched to Netmiko 🙂
But I’m also going to use serial cable as well for new devices
i wanna program a chat room in python using socket programming
tutorials just host the server on localhost
wat if instead i wanna host the server on an actual server?? (n how to do it?)
You're going to need to host your server script on some hosting service and connect to the server's IP in the client scripts
what does this mean
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000017E88672100>```
I'm on windows 11
If you guys have any experience working with sockets and ngrok, I have an interesting problem I have not been able to solve combining django with sockets for networking between server and raspberrypi. Full question: https://stackoverflow.com/questions/69503197/ngrok-with-python-and-raspberry-pi
Or Join
#code-help-voice-text
Hi very important question. Does anyone know how to use wireshark? how do I find the number of packets sent between 2 IP addresses? Thank you
did you figure it out? You could just filter the capture by source and destination and go from there..
So many sources bro...Youtube..google are good starts.. Learn the OSI Model. Learn subnetting. Learn layer 2 and layer 3 networking protocols..
perhaps
what do u need help with
Every request contains something called a HTTP header, it's how the packet knows what information to grab or rather send. Majority of requests contain TLS/SSL which is an extension that encrypts data that's being transported
To start off I'd learn the OSI model, but not the TCP/IP model even though that is what's real, OSI has deeper understanding
Thank you very much!!
Hi everyone is there a standard tool thats used for api documentation/design?
related to this, any good tools for general code documentation
you can check out openapi
if you're using something like fastapi it has pretty good support with that and will generate api documentation automatically
can I use it for designing the api as well?
I'm planning on writing the documentation for the core API first then developing it using the docs as spec
do you mean general restapi design patterns?
not sure what you mean but I just want to design the API before actually making it, regardless of the pattern used
although I do also need to look into design patterns
I'd still look into openapi, theres also a "swagger-editor" which you can use to edit the openapi schema, there's also postman which is commonly used
im not aware of any "general" all-in-one solution, there are different tools for different parts of the job
how would you go about designing an api initially then?
probably just draw, e.g flowcharts or mind-maps, if thats what you're looking for then you can check out whimsical. Google also has some resources on patterns/conventions used in api design
thx 🙂
are you familiar with JWT's btw?
thats pretty much the last thing thats been tripping me up because I cant decide how I want to handle authentication
yeah I do find it useful when there's authentication involved
my issue is I dont see how its secure
and I cant invalidate a single token
Hey Everyone - stealth stage startup here with recently secured Series A... looking to bring onboard some Algorand devs with Python + Java experience 🙂 DM's open
I thought of maybe storing a randomly generated secret for each user instead of using a global secret that way I can change their secret when I need to invalidate a token
but everytime I look it up people say thats defeating the purpose of JWT's since its supposed to work without having to make any calls to the DB, ut in my case I plan to have only 1 DB linked to all my servers anyway
and then I also have to the issue with persistent sessions, I've seen the idea using refresh tokens but I dont see the point of it since I could just assign a token with no expiry date to serve the same purpose
If you guys have any experience working with sockets and ngrok, I have an interesting problem I have not been able to solve combining django with sockets for networking between server and raspberrypi. Full question: https://stackoverflow.com/questions/69503197/ngrok-with-python-and-raspberry-pi
or join #help-pear
dont know what your issue is, but if you just want to communicate between client and server have a look at websockets
https://websockets.readthedocs.io/en/stable/intro/index.html
Requirements: websockets requires Python ≥ 3.7. Installation: Install websockets with: pip install websockets Basic example: Here’s a WebSocket server example. It reads a name from the client, send...
much easier to use the examples should give you everything you need in a few mins
I am already using sockets, and it is between a separate device(raspberry pi) and server
not sockets websockets
its different
i know, and I am currently using sockets
im saying try websockets instead of sockets you can achieve what you want a lot easier
I thought websockets only worked between pages?
Like on a site
no it the client doesnt have to be a website
Awesome, Will give it a look
it just has to be able to make calls to the websocket server so another python script can act as a client
hello, I'm writing a discord bot using a cloud IDE and everything is working. Now, I want to host the bot on my computer but I don't even know where to start. Could someone point me in the right direction, re: how to host a bot discord locally using python?
if ip is set to localhost in server
ok nvm
anyone help me in solving this error #help-avocado
dont know if u still need help with the jwt stuff but jwts are supposed to be stateless, so you dont need much state on the server side. Aditionally, having a jwt with no epxiry date would be a big security issue
got some help on the security chat, decided to go with generating secrets for each user stored on the db alongside their info, with a universal pepper stored as an environment variable
I plan to have the tokens have an expiry date of 1week and on each request the client checks the tokens expiry date if its less than 1 day ask for a new token
what do you think of this approach?
this way I can invalidate a single token by changing that users secret (salt)
btw is a token with no expiry date a risk because if someone gets it they can keep using it indefinitely, assuming they dont get flagged for suspicious activity?
yes, ideally you want the token to have as small expiry time. The point of jwt is that the access-token has usually a very small expiry time (maybe 30min) and then you have the refresh token with a longer expiry. Each time the user generates a new access token, using a refresh token, all other access tokens would get invalidated
I'm thinking I could also change the salt every time I generate a new token this way if an attacker gets a users token, when one of them refreshes the other will need to sign in again
and I would know that the users token has probably been compromised
and once a token is expired the user has to enter all his credentials again
so I give them 2 tokens one that they will only use to get new tokens
and one with a short expiry time that they will use for authentication
yes known as the refresh token, its there so the user doesnt have to type in his credentials all over again all the time, only like once a month or 60 days
how is this more secure though?
is it because its being passed around less so its less likely to be intercepted?
I feel like if an attacker can acquire an authentication token then they can probably also get the refresh token
unless there is an attack I'm unaware of
if an attacker compromises a refresh token and then generates an access token then the actual user's access token would get invalidated by the server, so the user would require to enter his credentials again and then generate a new pair of access and refresh tokens
but this assumes that the user doesnt ask for a new token while the attack is happening
if the attacker waits until the user stops interacting with the server they have a window where this doesnt work
but the idea is similar to what I had in mind
I think what I could do instead is have tokens with 7 day expiry times but on every request I generate a new salt and a new token for the user
this way I dont risk anyone getting hold of the refresh token and the user will have to sign in on their next visit if their token was compromised
what do you think?
it effectively works the same way as the refresh token but without the issue with the attack window
only issue is I'm not sure how expensive it is to generate a new salt and token every time
it would actually destroy all access tokens including the refresh token (causing everyone to re-authenticate)
actually this is fine its around the same time it would take with refresh tokens
everyone has a unique salt in my approach
I will store it in the db with their user info
so it only invalidates a single users token
I think your approach is probably just fine too
the whole point of jwt is thats it supposed to be "stateless", if you introduce some server-side state its just fine too
I'm thinking with my approach I can use tokens with no expiry time as well since it doesnt change anything security wise in my case from what I can see
yeah that part always confused me though since the user would still need to be in the db no?
with my approach the server still wont need to store any state about the user, it just has to be in the db
there can be problems if you want to introduce multiple devices of a sort in the future, then you might need to change some parts of the implementation though
what kind of issues?
if device b signs in then wouldnt that invalidate device a's token?
ahhh that is true
hmm I think what I can do is store a list of devices for the user
but to login with each device they need to type their password first
I would also need to store a salt for each of these devices
wait now that I'm thinking about it doesnt refresh tokens have the same issue?
its not really a problem that the refresh token is trying to solve, thats more about the implementation detail of how a system uses jwt
I think I've figured a way around it
for each device the user signs in from store a salt related to that device
and in the payload have the device name so that I know which salt to use
instead of having to check against every devices salt
the salt is only 32bytes as well so there shouldnt be any issues with storage even if the user signs in to a lot of devices
@narrow oak do you know of some persistent unique value I can use to identify the device the client is running from though?
it doesnt have to be universally unique just very unlikely that two of the users devices have that same value
and it needs to never change
depends on the platform but for the web you're looking for a "fingerprint", maybe check out fingerprintjs
this value never changes for a user if they use the same browser on the same device correct?
yes its supposed to stay the same
nice thats perfect then, if it changed I would end up adding a new device every time slowly storing useless data
unless I removed devices from the db after some time but I feel like that would cost too much compute for the storage its saving
thx for the help again, now my website is hopefully secure 🙂
any ideas how to realize P2P package distribution? any cool new tech that could be used to realize it?
bittorrent
What is a Subnet ?
You could ask that question to any search engine. Is there something in particular you're having trouble understanding about subnets?
What does the q=0.8 mean in headers for a request? specifically in the accept parameter?
for example: "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
This question I couldn't google 😦
the example has q=0.9 twice..
and q=0.8 once
I'm not sure why they used 0.9 twice, but the q parameter is used to denote preference - it must be a value between 0 and 1, 0 being least preferred encoding.
From the spec:
Each media-range MAY be followed by one or more accept-params, beginning with the "q" parameter for indicating a relative quality factor. The first "q" parameter (if any) separates the media-range parameter(s) from the accept-params. Quality factors allow the user or user agent to indicate the relative degree of preference for that media-range, using the qvalue scale from 0 to 1 (section 3.9). The default value is q=1.
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Quality factor is something i need to research too
Atleast for now we know the value range
Im sure this value means different things for different webservers
Ok; so random choices between 0.8 0.9 and 1 for scraping I guess.
The complicated part is parsing the robots.txt to make sure I am okay with the terms of service.... I wonder if there is a library for this that exists to parse robots.txt
@steady horizonAlr
I'm here
I get the classic timeout winerror10060
However if I ran the same code on my main computer I wouldnt get the error
🤔
If ip plays a role ill do some example ips
so my servers ip is 192.xxx.xx.1
and the clients is 192.xxx.x.254
Do your clients use the IP given by ipconfig (if you're on Windows) from your server?
I don't know what might be causing this then
Do you have any server-client networks that work I can take a look at them and see whats different?
In no more than forty five minutes
Alright want to give it another shot in 45mins when ur back at ur pc?
Yes
Ok cheers dm me when ur back
Okay
btw you don't need to redact 192.168.x.x ips, they mean private network or smthing
Hi everyone, I am trying to build a basic chat with sockets, but it will only work on my network. How can I make it cross network (two computers on different countries)?
<------------------------------------------------------------------------------------------------------------->
Server:
### imports ###
import socket
import sys
import time
### init ###
s = socket.socket()
host = socket.gethostname()
print(f"The server will start on {host}")
print("<--------->")
port = 64677
s.bind((host, port))
print("Server done binding to host and port successfully")
print("<--------->")
print("Server is waiting for incoming connections...")
print("<--------->")
s.listen(1)
conn, addr = s.accept()
print(f"{addr} has connected to the server")
print("<--------->")
print("Connected to chat server")
print("<--------->")
while True:
# send msg
msg = input(">> ").encode()
conn.send(msg)
# recv msg
incoming_msg = conn.recv(1024).decode()
print("Other: " + incoming_msg)
<------------------------------------------------------------------------------------------------------------->
Client:
### imports ###
import socket
import sys
import time
### init ###
s = socket.socket()
host = input("Enter the host name: ")
port = 64677
s.connect((host, port))
print("connected...")
print("<--------->")
while True:
# recv msg
incoming_msg = s.recv(1024).decode()
print("Other: " + incoming_msg)
# send msg
msg = input(">> ").encode()
s.send(msg)
<------------------------------------------------------------------------------------------------------------->
this looks so cool lol
Host need to be set to 0.0.0.0 to allow for connections outside of your network
Also you need be accessible from different network (you need to have public IP)
THX
I will try thank you
how do I get one?
I don't understand much in this subject
Buy VPS or something similar
if you are hosting yourself, you need to port forward to allow connections through your router
i have a guide in pins
does anyone know why the loops are set? It doesn't make sense because there's no iterative values in the set variables
This is Scapy btw
What loops do you mean?
for loops
the list comprehensions
I understand why the middle loop is set
but not the first and last ones
I'm guessing that IP is returning a generator, so the comprehensions would consume the generator output
wdym generator
or if like me you prefer videos
https://www.youtube.com/watch?v=bD05uGo_sVI
Python Generators are often considered a somewhat advanced topic, but they are actually very easy to understand once you start using them on a regular basis. Actually, after you use generators for some time, you will often find them more readable and performant than other options.
In this video, we will look at what a python generator is, how a...
The short version is, generators never produce all results at a time, they just produce one result at a time - so to print all of them, you have to greedily consume all of the things the generator yields first
so the index in the loop is set to just a decent amount for readable output?
List comprehensions do it implicitly, or you can do it with a for loop, or you can use next() passing in the generator to get each record one at a time
I'm not sure what library you're using or I would give you some examples
Generators are more memory efficient than functions that return all results at once, because often each result can be discarded before reading the next one. I think that's what you're asking?
Scapy
I'm using the CLI version atm
Ok they're not using generators, this is some custom dark magic lol
IP object is not an iterator, yet it is, and yet again it behaves differently in a for loop than a comprehension. This is some wild stuff.
Ok so comprehension is showing the repr() of each IP in the /30, whereas str() does not return a nice output but instead raw bytes.
Yep, that's why there are 4 IPs in the object returned when you call IP
ngl this is a pretty cool library
>>> a = IP(dst="www.slashdot.org/30")
>>> type(a)
<class 'scapy.layers.inet.IP'>
>>> a
<IP dst=Net("www.slashdot.org/30") |>
>>> type(a[0])
<class 'scapy.layers.inet.IP'>
>>> a[0]
<IP dst=Net("www.slashdot.org/30") |>
>>> print(a[0]
... )
WARNING: Calling str(pkt) on Python 3 makes no sense!
b'E\x00\x00\x14\x00\x01\x00\x00@\x005/\n\x00\x00\x0e\xccDoh'
>>> a.show()
###[ IP ]###
version = 4
ihl = None
tos = 0x0
len = None
id = 1
flags =
frag = 0
ttl = 64
proto = hopopt
chksum = None
src = 192.168.123.456
dst = Net("www.slashdot.org/30")
\options \
that's the one I've always used
!e ```py
import ipaddress
joes_addrs = ipaddress.IPv6Network("2a0f:85c1:23::/48").num_addresses
print(joes_addrs)
@cedar forum :white_check_mark: Your eval job has completed with return code 0.
1208925819614629174706176
I'm such a noob, is it common for a 16 year old to be learning this
you can do this at any age ¯_(ツ)_/¯
i'm only 18, I definitely used scapy before I was 16
idk but it definitely makes you way cooler than things like vaping
lmfao
it's just a generic name
what it's telling you is you can just do a[0] to display the packet contents iirc
rather than running a print
ah wait, I know what it's telling you
I think it wants you to call bytes instead of str
>>> str(a)
WARNING: Calling str(pkt) on Python 3 makes no sense!
WARNING: No route found for IPv6 destination 2a0f:85c1:23:: (no default route?)
"b'`\\x00\\x00\\x00\\x00\\x00;@\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00*\\x0f\\x85\\xc1\\x00#\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'"
>>> bytes(a)
WARNING: No route found for IPv6 destination 2a0f:85c1:23:: (no default route?)
b'`\x00\x00\x00\x00\x00;@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00*\x0f\x85\xc1\x00#\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
iirc = if i recall correctly
that reminds me I need to try get ipv6 working on this network again
lol
ipv6 is honestly brilliant
you don't have to write addresses out in full
for example, 2a0f:85:: is a valid IPv6 address
yeah
I used to browse on that IP
but IPv6 is great, SLAAC is great and globally routable addresses are great
we still don't have ipv6 on uni network, but i didn't at home either
so I wireguard tunnelled to a nearby PoP that did have v6
and then used that
but wireguard doesn't work on uni network 😔
universities usually have crazy big IPv4 netblocks, they will be among the last to transition
we've got a /16, so 65k addresses
amazing lol
how do you run out of 65k public addresses?!
we have 65k devices on our network and not everything gets nat'd
I think that the halls are now natted, but lab machines actually need unique public IPs
yes - but these are machines that need SSH open and similar things
we have a huge number of machines that have need for public IPs
that sounds terribly unsafe
it's all firewalled
mhmm
NAT is not a security measure
true
even if the morons at the IRS claim it is
but inbound port forward is a security concern
I'd be amazed if all of those many SSH endpoints are secure
They ought to have a jumpbox instead and use a single IP
as far as I'm aware things are solid, it's firewalled so that things can talk between our campuses in uk and also in china & malaysia
we are moving to bastions yeah
Hey guys, I’m planning on becoming a networking engineer, analyst. Do I need a degree in computer science to become 1?
but i think realistically we'll move to v6 in a year or two
Hello kind gentlemen, This code isn't working for me. I have tried these alternatives
with open('user.yaml', 'r') / with open('user.yaml', r)
we're already moving internally
Nah just get some Cisco certifications!
you're best asking through #❓|how-to-get-help 😄 this is for networking stuff
Really?
it's good to have some sort of qualification in the area, not necessarily cs though
You want open('filename', 'r') I think, or in Python3 this is the default with just open('filename')
What are someone other options I can do?
internships/apprenticeships maybe
I know several people who have gotten into network jobs with just a CCNA and no experience, and a couple of them are now engineers after a couple of years in local businesses
Also, I’m in grade 11. I’m taking the Cisco CCNA course. Will that be help me in the future?
I'm about to launch the first SSH bastion where I work, coincidentally
for sure, CCNA is pretty standard in terms of networking quals
Everyone always needs more networking people
Right now I’m taking the ccnav7 intro to networks course
nice nice, we decided in the end to go with wireguard instead of bastions, run an internal DNS server so you just boot the tunnel and ix2mail01 and ix2dc01 and so on just work, it's quite nice
and for pydis we just don't use ssh 🤡
Also if you get into other CS fields like security, development, or system operations, having a solid network foundation will put you ahead of most people in many ways.
Oh, alr
Oh I hate you this is what I was planning a bit ago but *ahem* circumstances forced me to improvise
hahahaha
so jealous
Wait so what Cisco qualifications do I need? Do I need to take an exam?
I just really love networking
Yeah the CCNA exam
CCNA is the standard, if you want to be able to put it on your CV you need an exam yes
Oh, alr
As a student you can usually find free vouchers to take the test
Really?
yeah, there are a few things out there, make sure you are sure it's legit though
Ok
ah true there are probably lots of CCNA-related scams, just because there's so much money around it
if you do find somewhere to do work exp/internship they might also pay for exam, so that is another avenue, but I have heard of vouchers for free/reduced exams
cost without any sort of vouchers is around £250 iirc
which is actually quite low for an industry qual, mine cost uhhh
£14,000 in total
expensed on the taxpayer 😎
Wait so can u clarify sum for me? I can get a job as a netowkring engineer, analyst, etc, etc with just a ccna qualification, but if I had a degree in say cs what does that do for me?
That will probably depend on the HR department at the place you want to work, unless you want to work for the government in which case there will be explicit requirements for a degree most likely
some hiring boards set the minimum bar as a bachelors in cs or a similar subject, so there is more opportunity with that under your belt, not to say there isn't opportunity without, it just gets you through the door
Oh, ok
and yeah, gov requirements is another one, say you were non-US based and wanted to work in the US for a H1-B you need a bachelors
the exam is just CCNA, you'll need to find a testing centre nearby you that provides that and pay the fees/find legitimate vouchers
in the UK at least Pearson VUE is the testing centre I think CCNA is sat at
Ok, ok
just make sure you have done practice tests and score well and read CCNA material, it might be worth buying media that's put out for CCNA because if you do have to pay it's a lot of money to not get the qual
Where I live, you can get vouchers through the local community college with Pearson Vue
https://study-ccna.com/ is a good one
*laughs in failing the OSCP*
I mean I haven’t finished my ccnav7 course yet, but so far I’ve done 1 exam and I got 100 percent on it. We’ve also been doing packet tracer assignment which really enjoy and I’ve been acing on all of em
Ty!
yea packet tracer is cool
I’ve also done labs where we configure real switches, routers, etc
that sounds very neat yeah, all good things to be doing
top thing to get into networking is have some sort of networking lab that you can learn and play with - even if virtual it's neat
Ye
vyos is a great free alternative to ios with a similar user interface, although Cisco is moving towards doing everything through web interfaces now and other madness like running containers on switches because (I'm pretty sure this is true) that company is run by the Joker
lmfao
vyos is neat
if you want to get into the nitty gritty like I did playing with BGP is cool
AS211224 (Joe Banks)'s is a IPv6 only network that is peering with 13 other networks and has 2 upstream carriers
playing with BGP is cool
Careful, you might trigger any Facebook engineers reading this
Tried both. no luck
I can go toe to toe with my director of network design on nearly everything except BGP. BGP is where I acknowledge that he deserves his salary of double what I make.
hahahahaha
Oh sorry you also need to end that line with a colon (:)
hopefully I'll be present at a physical exchange at some point
can peer with some other real networks, not just virtually
that's when I become a bit cooler
Ok more than that actually, you need to do with open(...) as stream:
Here's a dirty one-liner I like to use:
data = yaml.safe_load(open("file.yml"))
It's dirty because it can raise multiple kinds of exceptions from a single line
which means I usually pair it with other dirty patterns like bare exception statements lol
Hey guys, when I finish my CCNAv7 intro to networking course will I get a certificate?
only if it involves an official test
It has official exams made by Cisco
Can you ask your instructor?
Then it has an official final exam at the end of the course
Yeah I’ll ask my teacher about it
Thanks! I was able to see where I messed up on the first line.
It sounds like you'll probably be able to be certified, but the teacher will know for sure
What a great opportunity. I loved coding in grade school but my parents always said, "No one is going to pay you to sit at your computer and think all day." I'm glad it's taken more seriously these days.
Yeah. Ok so I’ve done a little research. Basically the ccnav7 course gets you prepared for the CCNA exam
If you also finish the course with a high score on your first try u get a huge discount on the CCNA exam
If you'd told me years ago that one day I'd feel dirty for working in education, I wouldn't have believed it, but wow that sounds like such a grift and so typical of modern "education" facilities.
That said, I'm sending you a friend request - no need to accept it now, but if you have trouble rustling up the scratch for that exam when the time comes, hit me up
Hey, I am trying to visualize a network that constantly changes with python, I basically want to show 5-10 elements in an horizontal line and change the arrows from and to each element, example -
Hey all in your words how does python interact or is used in networking?
Hello everyone! How do I display the image from Google Earth by giving the valid co-ordinates in ".png" help will be appreciated!!
What is subnet ?
A range of addresses on a network
Usually a subnet is in the context of something like a routing table
lemme try and draw up a little diagram
Here's a small example network with 6 hosts on 2 subnets, 3 hosts on each subnet.
These two subnets are connected by a switch, which has 3 cables plugged into it.
I meant to name eth3 eth2, so lemme just fix that
When you see 172.28.0.0/24, there are two parts to this:
172.28.0.0
/24
the /24 is how long the network mask is - the network mask is a measure of how many bits of the address are used to identify the network.
The rest of the bits are used to identify the host.
So 172.28.0.0/24 is basically a range of IP addresses.
The first 24 bits (3 bytes) identify the network - the last 8 bits identify a host on that network.
In other words, 172.28.0.0/24 is the network from 172.28.0.0 - 172.28.0.255.
172.28.1.0/24 is the network from 172.28.1.0 - 172.28.1.255
Both of these subnets are part of the larger 172.28.0.0/12 network, which spans every IP address from 172.28.0.0 - 172.31.255.255
Though this network only uses 6 of those possible IPs.
When setting up routing tables, firewalls, and that kind of stuff, you can set up different rules based on which subnet a host is on.
In the case of our switch here, when the switch receives traffic for one of these subnets, it needs to know which interface that traffic should be sent over.
Let's say the switch receives traffic destined for 172.28.0.2. Which interface should that packet be sent over? @thorny echo
eth0 of course. And it knows to send it over eth0, because the routing table says to send all traffic on the 172.28.0.0/24 subnet over eth0
172.28.0.2 is on the 172.28.0.0/24 subnet, so the switch sends it over eth0.
Now let's say 172.28.0.2 sends a reply, and it sends that reply to 172.28.255.4
172.28.255.4 isn't on any subnet in the routing table - so the switch sends the response over to the default, which is eth2.
So after fighting with Wireshark for almost 2 weeks, learning a bit on how to use it and learning the fundamentals of networking, I realised that what I've done is useless and I might need to learn something else to do what I need.
Has anyone here set up a transparent proxy? Can you recommend me what program could I use in Windows or Debian Linux to be able to get the https requests locally from my very own device?
What do you mean by transparent proxy? I used socat iirc as a proxy
I just need some means to be able to set up and check the traffic on certain websites that block the use of console. Specifically check where the data stream is redirected from, just the url and maaybe the IP of the server.
I'm not fully aware if I can share some examples with you, but let me know if I can paste some websites.
You can use nfqueue and create own proxy which relies on iptables
I see, thanks for the tip. I might come back after reading a bit on that if I still have questions.
!pypi NetfilterQueue
I used this few years ago 
ah that range from a certain number of IP addresses and 0 and 255 are reserved
so all that is Subnet right ?
But what is it purpose, and is subnet LAN, MAN or WAN or what ?
what is the differences between s.send and s.sendall? is there a difference when i do s.recv in client?
Is it possible to have async and non async inter process communication? I have a flask webspp running snd would like it to interact with my discord bot, without blocking anything
you could still communicate with each other yes but you might want to use something like threading on the flask side, maybe even consider something like fastapi if you want an async microframework
Oh have one thread for the bot and one for the flask?
are they on the same python process (in the same script?)
^ You don't need two processes for this, you can just make them the same program
default Flask is threaded btw
it's done that way so that one request can't block the whole pipeline of inbound requests if the handler is slow.
each can get equal scheduling prio
No, I just run 2 terminals atm
So I can have a threaded async program and a sync programming running at the same time?
On the same program
I sssume that makes it easier to communicate
If they're the same program, then they wouldn't be an async and a sync program running at once.
But yes, you can absolutely run synchronous code and asynchronous code in the same process.
You may need and/or want to have a background thread which runs the async event loop
But I don't think you actually need that.
Ah okay, that’s probably what I’m looking for, I’ll do some more research on it and see what I can do. Thanks for the help!
It's probably the easiest thing to do if you don't feel like delving into how the event loop actually works.
Yeah I have a pretty decent understanding of how it works already, so I’ll also look into that
In case I need it
client = discord.Client(stuff)
def run_event_loop():
client.run(my_token)
evl_thread = threading.Thread(target=run_event_loop)
app = flask.Flask()
evl_thread.start()
This totally works though
The event loop will just run in its own thread and chug along happily
All the async code related to discord will exec in that thread, but you can still send coroutines to the event loop from flask's threads.
There's also an async version flask, so if you wanted you could have a single thread with a single event loop which deals with both flask and discord coros
Up to you
so is the default process basically a thread?
i see here you only made a new thread for the discord client
why not one thread for the bot and one thread for the flask?
yeah, quart, don't like the flow with that much though
A process has one thread by default.
Flask will spin up additional threads on its own automagically, but it gets ownership over the original thread.
So there will be at least two threads. One running the discord event loop, and one running flask.
oh i see, i assume discord.py doesn't spin up more threads and so we can safely place it in its own
Even if it did, it still needs one thread to take ownership over in this setup.
Both threads could spawn as many child threads as they want.
But afaik it won't spin up any, it'll just execute within evl_thread.
im trying to send JSON over a tcp socket in a while loop, the first time in the loop it works but the second time it tries to send over socket it gives an error
sock.connect((HOST, PORT)) OSError: [WinError 10038] An operation was attempted on something that is not a socket
hm maybe i shouldn't close the socket until outside the loop
hm that didn't work OSError: [WinError 10056] A connect request was made on an already connected socket
nice i got it, you need to open and close the socket inside the while loop
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) inside the loop
you shouldnt be creating and destroying a socket in a loop unless its to a different destination @hollow linden, why delete it and recreate it when you can send stuff through it more then once
im a noob and this is the first way I got it to work, the destination is a video game listening on TCP port @prisma cobalt
make once connection and send a bunch of stuff over it
Close that connection when you're done sending stuff
best way
when i do that, the second time i send somthing it gives an error
OSError: [WinError 10038] An operation was attempted on something that is not a socket
On what line?
The error is telling you the problem. You've tried to use something which isn't a socket as a socket.
If I had to guess, I'd say you're probably accidentally overwriting the variable somehow.
oh i think i understand now
i have sock.connect((HOST, PORT)) in my loop
i can put that outside and just call sock.sendall( inside the loop?
yup
You only need to connect once, so you don't repeat the connect() call.
The basic idea of TCP is:
Two sockets connect
The two sockets can send and receive as much data as they want
The two sockets disconnect
awesome thanks, that worked. better to learn how to do it the right way
thanks
anyone know socketio with python?
I am using socketio, what's up?
When someone connects to my socket server, it sends the packets on connecting. But there is a problem. The packet sent to the user is too large, I mean it sends a large packet to the user who connected to it. Is there a way by which I can divide packets into smaller packets and then send them?
I know in windows, there is a setting called "jumbo frame" that, when enabled, allows huge packets to be sent, but since you are on a server, I'm assuming you are using Linux
see its nothing that large, i am just trying to make a proxy server
when i send the whole website code to the browser, it wont load, and if i send small html code, then the website works completly fine
when client requests to the proxie server, the browser sends the headers to the socket server that the user just requested, and the socket server requests the website and returns source code of the website using requests module, that is just a socket server made with python, its just nearly 30 lines of codes. I want to breake packets into smaller part so that the browser can load it properly
or you can just guide me on how to make a proxy server in python completly from scratch.
Thanks in advance
Content-Length and Keep-Alive headers
A proper HTTP impl doesn't care about whether a request or response is broken up into many packets or just one.
The end of the request is indicated by consecutive new lines