#networks
1 messages Β· Page 31 of 1
Idk which you mean, but you should have everything here: https://api.mail.tm/
import requests
import json
payload = {
"address": "email",
"password": "pass"
}
making_account_thingy = {
"address": "username@solarunited.org",
"password": "helpmepls"
}
r_token = requests.post("https://api.mail.tm/token", json=payload)
things = r_token.text.split(":")
token = things[1]
headers = {
"token": token
}
r = requests.get("https://api.mail.tm/me", headers=headers)
print(r)
print(r.text)
This just kinda.... doesn't work lol
idrc about it lol
but ty anyways haha
Then idk. Sorry. I never used this one nor auth Token on API XD
np, thanks for trying to help haha
You are welcome π
Hey. Is here anyone who knows web3.py
from web3 import Web3, WebsocketProvider
import json
def check():
web3 = Web3(Web3.WebsocketProvider('wss://mainnet.infura.io/ws/v3/'))
web3.isConnected()
if web3.isConnected() == True:
print('connected')
else:
print('check your infura address')
new_transaction_filter = web3.eth.filter('pending')
new_transaction_filter.get_new_entries()
I have to get list of pending transactions using python and infura but now infura doesn't support web3.eth.filter and I on't know how do to it
I've got a question
Why does 20.120.47.225/13 has a netID of 20.120.0.0/13 and not 20.0.0.0/13?
/13 means that you have mask 255.248.0.0 so 20.120.47.255 & 255.248.0.0 = 20.120.0.0
But why 120 and not 0?
Hello, I want to mesure the delay between two machines communicating on my local network with ROS. I was wondering if I could send the current time with the time module and then mesure the difference between the real time on the receiving machine. Is the time module precise enough? I want an accuracy in the millisecond range
Your mask is not 255.0.0.0 but it's 255.248.0.0 - then id is IP address & mask
I think that the key is to synchronize time on both machines 
Is there a proper way to do that? What's behind a ping function
Speaking honestly I have never do that. You can take a look at this article https://en.wikipedia.org/wiki/Network_Time_Protocol
The Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In operation since before 1985, NTP is one of the oldest Internet protocols in current use. NTP was designed by David L. Mills of the University of Delaware.
NTP is intended to synchron...
I think that there are existing solutions in this area but you need to find some articles or documents 
[Q] requests lib:
website has in html:
<form id="formLogin">
<div class="login">
<input id="inputName" placeholder="Enter your name" type="text"/>
<button type="submit">
... etc...
It's under url lets say abc.gg, I want to log in so I can access next page, I do:
url = 'http://abc.gg'
payload = {'inputName' : 'JohnDoe'}
r = requests.post(url, data=payload)
It says cannot post 404 error, so I do get:
url = 'http://abc.gg'
payload = {'inputName' : 'JohnDoe'}
r = requests.get(url, data=payload)
Still doesn't work. How do I access payload of inputName this html tag:
<input id="inputName" placeholder="Enter your name" type="text"/>
How to acces that inputName to set my value and send to website?
@charred mesa I've removed your message as it's not on topic to this channel. Please ensure you stay on topic in future.
ok, do you know what channel is of this topic?
as per the channel name, networking. channel descriptions also goes into detail over allowed topics.
i think he meant what channel was best suited to his particular question Scragly
yes but i already had an answer on it, thank you
π
Does anyone work with raw sockets?
Me a little
i do
Is there any steps to securing a server socket allowing connections from anyone aside from making a bash script to block IP's that don't follow the sockets protocal/have an ID at the start? I'm planning on making a app, but I don't feel like getting hacked due to bad socket practices.
Hey guys, do I need any sort of prerequisite knowledge to start learning networking? or is basic programming knowledge good enough?
what's that?
yeah
the socket library
how can make something that only accepts connections from certain IP's sure, just a python dictionary lookup table, or even maybe a set idk π€·ββοΈ
does anyone know how to find ip address on Vsphere all vms are showing same iP
{'value': [{'name': 'vmnet4', 'type': 'STANDARD_PORTGROUP', 'network': 'network-3291'} what does network represent here??
I did gave that a thought fir a brief amount of time, and all i could come up with was to first let any client connect to teh server and the authenticate it based on a password or smthng, and if authentication fails, close that connected socket. The that'd require having a database of clients registered on your app, makes it similar to allowing only some specific client IPs or sockets pre defined in a data struct to connect to the server as evorage suggested above. For an app, I'd suggest making a separate registration section where users firat have to register themselves so that their ip, and passwords get stored for later authentication, and then come back and login to use the actual app
Ye lol i do
Yeah lol basic to intermediate knowledge is good enough to start with something like sockets
ah, so there's no difference between sockets and raw sockets, I'm so dumb
!e
import sockets
@trim moth :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'sockets'
There's no module called "sockets" while what he meant by "raw sockets" was the "socket" libarary.
mind the "s"
!e
import socket
Yeah I got it, just can't believe how dumb I am
lmao happens
Hello everyone
So I just got
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
error when trying to get my client to connect with the server.
My code is the following(written in Python)
Server:
#!/usr/bin/env python3
#server
import socket, ssl
HOST = '192.168.116.132' # host IP
PORT = 56789 # Port to listen on (non-privileged ports are > 1023)
context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
context.load_cert_chain(certfile="./server.crt", keyfile="./server.key")
bindsocket = socket.socket()
bindsocket.bind((HOST, PORT))
bindsocket.listen(5)
print("Connected.")
while True:
conn, addr = bindsocket.accept()
connstream = context.wrap_socket(conn, server_side =True)
data = conn.recv(1024).decode()
if not data:
break
print("out: " + str(data))
conn.send(data.encode())
try:
deal_with_client(connstream)
finally:
connstream.shutdown(socket.SHUT_RDWR)
connstream.close()
def deal_with_client(connstream):
data = connstream.read()
#null data == client finished with us
while data:
if not do_something(connstream,data):
#if return false, done with client
break
data = connstream.read()
#done with client
And client:
#!/usr/bin/env python3
#client
import socket,ssl
HOST = '192.168.116.132'
PORT = 56789 # The port used by the server
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
context.verify_mode = ssl.CERT_REQUIRED
context.check_hostname = True
context.load_verify_locations('./rootCA.crt')
conn = context.wrap_socket(socket.socket(socket.AF_INET), server_hostname = HOST)
conn.connect((HOST, PORT))
cert = conn.getpeercert()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
while True:
message = ("hello world!")
s.sendall(message.encode())
data = s.recv(1024).decode()
print("In: " + data)
```
I was given these as references: https://docs.python.org/2/library/ssl.html#client-side-operation
https://docs.python.org/2/library/ssl.html#server-side-operation
However I am unsure if I implemented it correctly.
For context, am following these instructions: https://pastecord.com/yjafoqobag.sql
Otherwise...things have been working so far so good..but the certification to work is frustrating.
And I am using two separate VM machines, one for client, and one for server in doing this
</div>
<div class="trn-defstat">
<div class="trn-defstat__name">Total XP</div>
<div class="trn-defstat__value" data-stat="PVPTotalXp">
15,935
</div>
How can i use urllib.request & BeautifulSoup to pull data number inside PVPTotalXp ??
i want it get data and print out 15,935 only
can anyone give me an idea how to make a chat program that will connect two particular computer and enable to chat. No GUI is required. A begining project. Keep it simple
where
where
chair
I am sitting on chair
π€¦ do you want to know how to do this or not
what to pin or the code
no, you dont know how to access pins, are you on a computer or a mobile device?
yeah I know
yes I know
I don't want to know anything but please help me with the chat application
Thnx a lot
thnx
lol ,m dead
lmao
π
lol
So the ethernet frame on a wireless nic, the source and destination are a local reference correct?
The mac address is typically the local "ethernet" mac on the wireless card
Ethernet frame on WiFi 
?
[Q] Requests lib - POST payload:
Hi, Im trying to post payload to website. From the Dev Console (network tab) I found it needs "request payload" like this:
123:42["userData",{"name":"Doe","code":"","avatar":[9,31,13,-1],"join":"bz1nPvY09I1A","language":"English","createPrivate":false}]
I think I sent data properly, even 2 different ways, but I get 404 error:
#1 First way
url = "..."
payload = {"name":"John", "code":"", "avatar":[6,6,9,-1],
"join":"bz1nPvY09I1As", "language":"English", "createPrivate": "false"}
r = requests.post(url, data=payload) #NOTICE DATA=...
print(r.status_code)
#2 Sceond way
url = "..."
payload = {"name":"John", "code":"", "avatar":[6,6,9,-1],
"join":"bz1nPvY09I1As", "language":"English", "createPrivate": "false"}
data = json.dump(payload)
r = requests.post(url, json=data) #NOTICE JSON=
print(r.status_code)
Why 404, is payload constructed wrong?
Not sure if it's the problem but your example from the dev console has a JSON boolean true whereas your payloads have a string "false"
Oh and you don't need to serialise to JSOn twice....
(in the second one)
requests json= will correctly serialise python booleans to JSON booleans so you can just put it in as ```py
{"name":"John", "code":"", "avatar":[6,6,9,-1],
"join":"bz1nPvY09I1As", "language":"English", "createPrivate": False}
Tag ^^^
Hey can someone please help me with the shoppy API pleasee, ive been struggling for quite some time now
lol
Hey guys, I am new to development. Though I have been solving comptetive programming questions but i kinda wanted to create a Facebook bot.
The thing is i have to moderate a live session on Facebook in which people ask questions and i have to copy these questions and paste them onto Google docs so that the host can read the questions.
Can this be automated by a Facebook bot made in Python? If so, could you guys please provide me an outline to how should i start studying in order to create this bot.
Requests lib - POST payload help needed
Anyone prefer me any pdf networking tutorial?
and also networking modules(except socket) pls
check out the requests module, i think there's a http module too
im trying to get any incoming data then send it to all the clients. I'm a beginner. What am i doing wrong?
try:
msg = s.recv(BUFFER)
for client in clients:
client.send(msg.encode(FORMAT))
print(f"recieved message: {msg}")
except:
continue
your encoding an already encoded msg since you never decoded it
also is clients a list of sockets?
ye
okay remove the .encode(FORMAT) then
no its not, its just not supposed to be there
msg = s.recv(BUFFER)
for client in clients:
client.send(msg)
print(f"recieved message: {msg}")
but this still doesnt seem to fix it
also are you sure? if i dont encode it then it throws an error
okay you recv it in its encoded form yes? so its already encoded and you dont need to encode it again
show me what clients is if your getting an error
oh your right
i didn't think of it like that
def sendMessage():
while True:
msg = str(input())
try:
s.send(f"{name}: {msg}".encode(FORMAT))
print("Sent message!")
except:
continue```
this is client
if i remove the try
i get this ```
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\threading.py", line 954, in _bootstrap_inner
self.run()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\RawrI\Desktop\python projects\Chatapp\server.py", line 23, in listenForMessages
msg = s.recv(BUFFER)
OSError: [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```
if i do s.recv does it get it from a specific client?
I was able to solve it
i realized i was doing s.recv() as in i was trying to get info from itself lol
i just put the clients in a class then constantly listen for data that way
thanks @prisma cobalt
π
looks like your recving a character not in the utf-8 character set
Whats the kind of data you're receiving?
If it's text data encoded with encode(), the decode method should be able to decod it into a string, apparently, the data is from a file lll
hey everyone,
I own a host on digitalocean, and i have a apache web server running on it. i own a domain name on namecheap.com, how do i point my namecheap domain to my webserver host on digital ocean?
Define an A Record on namecheap that points to your webserver's public IP is prob the easiest
is there any library for controlling bluetooth
or recieving bluetooth signals
i have a microcontroller and a bluetooth i want to capture its data in my laptop
using laptops Bluetooth using python
i want to display data in my gui
i just want to know how to collect bluetooth data using python
i think the socket library can help you
no it can't
When you send packets via proxy server will see your proxy IP as a client IP
new to this channel
Welcome
thankyou man
lol
Ummmm keep track on which sequence or message it happens. It is probably due to the fact that utf-8 has 1 to 4 bytes encoded characters, so if you're unlucky with that 1024 random split it will go ka-boom
I have a hard time confirming my thoughts, from what I understand. It is two Pi that are connected wireless and using UDP to send a temp sensor package. I am trying to understand the time/event trigger solution and the pros and cons
Time-triggered solution is good because they have a set of specific intervals where the system expects a package every x min, which then makes it so that the allocation of CPU can be calculated beforehand. Are negatives maybe too expensive/redundancy?
Event-driven solution is suitable for small systems where you are only expecting very few events? Negatives hard to know when to expect an event/package loss.
Mixed solution will have both solutions, positives, and negatives.
I am sure that there are more and better examples of these solutions, and I would love it if anyone could elaborate more on this topic.
Hello, does anyone know how to fix a broken string in Python the problem is with the \ character, I get the whole string from API?
Here is the screenshot:
This is from my VS Code.
I have to fix this programatically.
Is this homework π
Is there any practical difference between using urllib.parse.quote() and urllib.parse.quote_plus(), and why may you choose to use one over the other? As far as I understand, the only difference is that quote_plus() encodes spaces into + instead of %20, but does it make a difference? Thanks in advance.
can anyone tell me if I am correct or incorrect
print("[+] Http Request >> " + packet[http.HTTPRequest].Host + packet[http.HTTPRequest].Path)
TypeError: can only concatenate str (not "bytes") to str
anyt ideas on how to fix?
"[+] Http Request >> " is a string, packet[http.HTTPRequest].Host is bytes which you can't concatenate (as the error says)
Try packet[http.HTTPRequest].Host.decode()
Swishy
@west mountain muli-line and not?
Sorry, what do you mean?
quote and quote plus , i wondered if the + was a multi line read ?
so no one answered and i just look it up
urllib.parse.quote_plus(string, safe='', encoding=None, errors=None)
Like quote(), but also replace spaces with plus signs, as required for quoting HTML form values when building up a query string to go into a URL. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to '/'.
I don't understand if there's any important difference between using %20 and +
Can selenium be used to send packages through a websocket opened by the javascript of the website and monitor the traffic going through said websocket?
could anyone look at my question ?
Not really, you'd just be using selenium to run a ks script
Your question doesn't massively make alot of sense e.g. Using TCP when this seems to require reliable transport of data??
Overall interval based sending would make the load more predictable yes
Hmm, what are the alternatives for doing it? I figure a proxy would work, but perhaps there is an easier way
Well if its a TLS socket e. G. Wss:// then their isnt really anyway to monitor what's actually being send
Activity wise though a reverse proxy / proxy might work ig
Okay, thanks π
Does our Internet runs on TCP/IP still? I know tcp was designed with security in mind so it already has a lot of security mechanism built-in.
You're you, perfect expression of yourself.
As for your question I don't get what you want to ask exactly. If it's about detection of errors then yeah time based seem to be working, but if you only have message every few minutes minutes why not just send it over TCP ? And if you have many receivers then hmm maybe some protocol like gossip might help you.
TCP wasnt really designed for security, it's just a protocol used for reliable data transmission, your internet can run on either TCP or UDP packets depending on what it is
things like FPS video games etc... are udp based because you need speed but not reliability of data
Well with UDP basically you get port, and TCP adds sequencing and confirmation of receivement and pretty much that's it
Well as a protocol UDP by itself is pretty useless. It almost always need some machinery to either detect message, or reconstruct message or get it later, or ignore it. But basically content matters so if it's just say a video stream uplink to many you don't give a damn given that the stream itself has some sequence points from which one can recover plus if it's a stream then one would need to sequence messages probably. But say it's just temp sensor, do you care about loss of one sample ? In the simples form yes timed events are easier to track if one message got lost but still some sequence might be needed.
You can just don't care about missing parts
In PS3 I used logger over UDP to a router and from there via built-in access router to my laptop over WiFi and well small messages in not so rainy day had quite good received to send ratio, but as one gets messages larger or more frequent the buffers might just overflow and messages can well go down the drain frequently
You can not
Nope?
Nope
When you have video conversation for example
If you want to receive and you never receive it is pointless
When you lost some packets you don't care
You don't need to record whole conversation
I got your point but still you imply you get something at least
Which is why UDP alone plainly is often not enough
Hmm it has the same socket behavior as TCP sockets do
just without the garentee of data being ordered and correct
although you often can set a checksum for the checking data correctness
Well in theory reordering shouldn't happen that often
things like QUIC implement reliable transport on top of UDP but that takes alot of it's speed away
if your network is good generally it's not a big issue
If its an app between two local host apps you likely wont experience any issues
maybe 1000 * 999
lets say there are 5 people
eacch number represents a person
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
2000 i guess then
does anybody know any ports for NA-WEST server in Fortnite
If possible pls gimme port for NA-WEST in California
π
how can this be so accurate
@ruby radish
data = conn.recv(1024).decode("UTF-8")
conn.send(data.encode("UTF-8"))
im good now haha ty
import socket
HOST = 'localhost' # The server's hostname or IP address
PORT = "8000" # The port used by the server
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
s.sendall(b'Hello, world')
data = s.recv(1024)
print('Received', repr(data))
can someone help me
hi,does anyone know about x-crsf-token?
im a beginner and i cant run this code
Can't run it?
i find whats problem thank you anyway
from requests.structures import CaseInsensitiveDict
import requests
url = "http://127.0.0.1:4384/api/"
headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/json"
data = '{"command": "update"}'
try:
res = requests.post(url, headers=headers, data=data)
print(res.status_code)
except:
print('Server closed')
How do I go about disconnecting after it sends a post?
anyone know the reason for a '403 error'
import socket
MASK = "255.255.255.0"
MASK_B = [int(b) for b in MASK.split('.')]
LOCAL_IP = str(socket.gethostbyname(socket.gethostname()))
LOCAL_IP_B = [int(b) for b in LOCAL_IP.split('.')]
NET_b = [ str(LOCAL_IP_B[i] & MASK_B[i]) for i in range(4)]
NET = '.'.join([b if int(b) > 0 else "255" for b in NET_b])
``` Sorry for the repost from [#help-honey](/guild/267624335836053506/channel/776184243570475048/), i just need a confirm for this algorithm, that must be translated in C, is this the correct way for finding the "broadcast address" for an udp client inside that should be inside any potential local network, assuming `MASK` is retrieved at runtime? If you're wondering, the goal is to broadcast the local IP of an IoT device ( only inside is local network ), so that an app in the same network can connect to the TCP server running for configuration.
Thanks in advance for all the suggestions/clarifications... I'd really appreciate them! π
uh well it's pretty messy
looks like it would get the job done
but most of the code is converting back and forth between data types
@stone dirge 403 is a HTTP status Code, to indicate that you are trying to use restricted files from the server. Restricted in the sense , You are not allowed to read that file.
How can I log my VPS errors to a Discord channel? Or at least a better method than using journalctl
@gleaming ivy from scapy.all import * solves all things
Anyone here play with scapy? I'd hoped ^ would spark chatter
I am doing a little blockchain project and I am opening up sockets to get instructions from nodes.. is this recommended? What is the best form for me to get instructions from nodes on my PC outside of my network by providing an IP and Port?
anyone dm me if you want me to tell you any exploitable vulnerabilities in your network
How can I reopen a websocket connection when it closes?
any projects to make which involve networking?
Hey folks! I'm trying to detect motion and people with opencv and deploy it with fastapi, but I'm having some trouble integrating the two. Details are in #help-potato. Could someone pop in and help out?
You can't, new connection has to be established and while the data stream is bidirectional, connecting itself isn't so if it was issued by them unless app somehow allows it to have some open port for client to connect back you can't. Alternative is to server to connect to you but it's less popular as you would need open for listening port and public IP or even use thirparty/buddy system.
The easiest seem to reconnect beck to server and using some session Id or from scratch rework the expected state
Some interesting things might be making your own HTTP client or making your own chat client and server and what-not
I myself learned quite a bit by making my own HTTP client
oh, what does a HTTP client mean exactly? i only know about raw sockets for now
Alright, so you know the requests library, right?
yes
so basically a program which can send and receive data?
like get and post requests
Yes
and so basically it's sending a payload formatted like
GET / HTTP/1.1
Host: www.google.com
No, sockets
epic, ill try
nm = nmap.PortScanner()
while True:
ip = input("\nInput IP address to scan: ")
if not ip:
break
print(f"\n--- beginning scan of {ip}")
output = nm.scan(ip, '22-1024')
print(f"--- --- command: {nm.command_line()}")
print("----- nmap scan output -------------------")
pprint(output)
ERROR: nm = nmap.PortScanner()
AttributeError: module 'nmap' has no attribute 'PortScanner'
anyone could help to solve this, I installed NMAP but still its not working on Pycharm
#help-lemon socket help needed at the mentioned channel
How can i update Exe files directly from visual studio code
thats not networking?
https://httpstatuses.com/403 is a good site for looking up HTTP status codes
HTTP Status Code 403: The server understood the request but refuses to authorize it.
#discord-bots teleport
I am trying to connect to Bitcoin nodes via sockets, is this safe? I just got a malware warning from my antivirus just from sending a GET request from the socket module in python
Firewall and anti-viruses are known to block sockets stuff and thats fine and pretty normal, just disable your antivirus/firewall and you'll be fine
hello
i would like to setup my server on an external network, so that someone from a different network can connect to it. how does one go about doing this?
utilizing sockets and listening through them?
yea thats what im doing but it only works on the internal networks, only on devices connected to the same network the server is hosted on
i want to go beyond that
import nmap
nm = nmap.PortScanner()
while True:
ip = input("\nInput IP address to scan: ")
if not ip:
break
print(f"\n--- beginning scan of {ip}")
output = nm.scan(ip, '22-1024')
print(f"--- --- command: {nm.command_line()}")
print("----- nmap scan output -------------------")
pprint(output)
ERROR: nm = nmap.PortScanner()
AttributeError: module 'nmap' has no attribute 'PortScanner'
anyone can help to solve this, please. I am using PyCharm IDE, Python3, Installed all necessary pkg to run it as I searched first from StackOverflow to solve it, but it is still now working for me.
Well when you are binding your socket to listen are you inputting your Public IP?
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
!pypi nmap
!pypi python-nmap
Which nmap do you have?
I want to learn python socket programming pls help
check pinned messages of this channel lol
pls help
ok
see this, this is for fire transferr, figure out how to transfer text data instead and make a chat app, and look at articles from "sockets in python" on google lol
ok
can we make a global socket meaning can we transfer ip to website for getting realtime chat website or app than rather on lan or pan
oh, websites, it could be a django website or something and take the text data and transfer to the clients using underlying sockets
not sure if this is the correct channel, mind me if not π
so i have a raspberry pi and i want to host a website on it with my own website adress. Do you know a good tutorial that teaches how to do so?
multiple websocket connections?
So basically i got a question. When sending requests, it's waiting for a response. Is there a way of speeding up the response time alot?
Currently using asyncio + sockets.
Sockets for request, and asyncio for running the requests.
I would recommend using the asyncio streams setup you're given by asyncio
there's alot of behavior you need to get down correctly to use the normal sockets and asyncio together correctly
Guys just how secure is communication through sockets with untrusted users?
err by default, about as trustworthy as turning up at another families home claiming to be the father (its not)
By default sockets are pretty much entirely plain text, and viewable by just about anyone who can see the data / packet of data
and there are plenty of attacks like man-in-the-middle attacks that leverage that fact and can alter the requests between the person you think you're contacting etc...
well thats about the same as any other data transfer in the sense that if you download it or have that data into your system then sure
sockets arent very complicated things
they just in lames terms shuffle data from one computer to another over the network
it does pretty much nothing to protect or secure you
where can I learn to protect myself?
I mean then how can I make sure the data is what I want
well the only way you can really truly be sure is several security layers and sandboxing environments
The real question is what you're doing with raw sockets with no abstraction like this really
Well I am just looking at the P2P system that bitcoin implements and how these guys are just openly communicating with random peers
well thats sorta an entirely diffrent system and setup
I mean I am recreating the communication myself in Python and my code is pretty bare
was TL;DR bitcoin and other crypto currencies work on the basis of trust no one
it works off the basis of there are no friends and everyone is trying to get you
alot of the design around it extends and its built upon a thing called blockchain
No yeah I know I mean I messed around with Bitcoin back in 2012 haha I mean I have a couple of million I lost by throwing my keys away back then.
I am trying to mess with the Nodes side of it
I am connecting with peers through a script I wrote but my worries are that I am not securing my socket connection?
I am just sending and receiving I have no security protocol in place and want to know if I should have one in place
well... it would probably be a good idea
there are a fairly large amount of attacks, data leaks etc... recorded in history just from http issues alone
because of the lack of encryption between server and client
you get essentially all those issues and more
but again, the whole crypto setup is built off blockchain and thats what makes it secure
the whole crypto setup is built off blockchain? or blockchain is built off crypto ? and I mean I don't even know how attacks can be sent through sockets, I am trying to find a read on this do you know of one?
I figure this Message Structure is how Bitcoin defends againts malicous attacks such as Malware?
Checking the first 8 bytes and making sure it's the magic value that is needed to communicate right? by breaking the message down? I imagine the len of a malware would be pretty long and a 8 bytes is pretty short for a malware?
but then it goes onto checking the len of the payload and then checking the checksum of the first 4 to verify that the payload is actually the payload that was destined to be sent
but I mean then the payload has an unrequired len so could reading this payload invoke a malware onto the machine?
Why am I not finding any reads on this through a simple search..
Or is this now how things work? if I open a socket its only sent to python? it can't run any code outside of it?
Hey all, I have a quick question regarding networking from within a docker container. If I'm using a python socket server and I do something like this:
server.bind(('localhost', 7634))
When I run this inside of a container with that port exposed, I can't seem to hit it. But if I make that into:
server.bind(('0.0.0.0', 7634))
I can connect to it. Could someone explain the difference and how I might be able to get the first method to work? I understand that 0.0.0.0 is more of a wildcard interface, but where is my connection going if not to localhost? Thanks!
hey python community, im trying to build a cryptocurrency (full nodes written in python, with clients made with Flutter/Dart)
anyone here know how to make the p2p network (needed to transmit transcations)
I need urgent help
I have made this python code (from raspberrypi.org)
from requests import get
import json
from pprint import pprint
from haversine import haversine
stations = 'https://apex.oracle.com/pls/apex/raspberrypi/weatherstation/getallstations'
weather = 'https://apex.oracle.com/pls/apex/raspberrypi/weatherstation/getlatestmeasurements/2387750'
my_lat = 28.541511
my_lon = 77.373089
all_stations = get(stations).json()['items']
def find_closest():
smallest = 20036
for station in all_stations:
station_lon = station['weather_stn_long']
station_lat = station['weather_stn_lat']
distance = haversine(my_lon, my_lat, station_lon, station_lat)
if distance < smallest:
smallest = distance
closest_station = station['weather_stn_id']
return closest_station
closest_stn = find_closest()
weather = weather + str(closest_stn)
my_weather = get(weather).json()['items']
pprint(my_weather)
Whenever I run this program and type my_weather, I get []
Is the problem with my program or the server?
Well, if I open those URLs in a browser I get what looks like sensible data so probably not the server's problem
its weather info so why theres problem
Your code won't run for me at all due to haversine being called with the wrong number of arguments
That might be a version thing I guess maybe
Oh
Have a close look at this line and what it's doing ```py
weather = weather + str(closest_stn)
And what the state of weather is before this line
I had to change the haversine call to be like ```py
distance = haversine((my_lon, my_lat), (station_lon, station_lat))
Hi, im looking for some websites to help me to learn the tcp/ip and internet process and have a very good knowledge about that. I would like to start to learn without python, then when i'll have a good knowledge i could use python.
Anyone able to help with the folowing:
import json
from ripe.atlas.sagan import (
TracerouteResult,
PingResult,
DnsResult,
SslResult,
HttpResult,
)
from ripe.atlas.cousteau import (
Ping,
Traceroute,
AtlasSource,
AtlasCreateRequest,
AtlasLatestRequest
)
is_sucess, result = AtlasLatestRequest(msm_id=29920648).create()
if is_sucess:
for x in result :y=json.dumps(x)
print ("{} {}".format("Source address",x['src_addr']))
print ("{} {}".format("Destination address",x['dst_addr']))
#print ("{} {}".format("Packet Sent",x['.packet_sent']))#
print ("Returns",x['.rtt_median'])
result = TracerouteResult(
json.loads(y)
)
print("{}{}".format("Address Family IPv4 ",result))
Error print ("Returns",x['.rtt_median'])
KeyError: '.rtt_median'
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Are you sure that there is a key .rtt_median? Maybe without dot?
https://paste.pydis.com/wodahegoso
Could someone please help me with this aiohttp error I'm getting? I don't understand what it means.
Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8
Mimetype should be application/json
What does that mean? Is it an issue on my end or the server's end?
If you expect JSON output from API it looks like issue on the server's end
Ah, I understand the issue now, thanks. I've been changing host address per query, and forgetting to append /api, meaning I was fetching the wrong data π
Thanks for your help!
Your welcome!
Thanks for the reply according to https://ripe-atlas-sagan.readthedocs.io/en/latest/types.html#common-attributes there is but i cant work out why its not working I've tried both with and without
As far as I see there is rtt_median attribute, not .rtt_median
Try this
print("Returns", x['rtt_median'])
print("Returns", x['rtt_median'])
KeyError: 'rtt_median'
Hmm, how about x.keys()?
Let see which keys are available
Returns dict_keys(['fw', 'mver', 'lts', 'dst_name', 'af', 'dst_addr', 'src_addr', 'proto', 'ttl', 'size', 'result', 'dup', 'rcvd', 'sent', 'min', 'max', 'avg', 'msm_id', 'prb_id', 'timestamp', 'msm_name', 'from', 'type', 'group_id', 'step', 'stored_timestamp'])
Address Family IPv4 Measurement #29920648, Probe #53347
Okay, there is no rtt_median π¦
Thanks for that its been racking my brains for the last 2 hours. Just seems strange how it states it can be done yet the command dosent work
async with session.get(
url,
params=params,
headers=headers,
raise_for_status=True,
proxy=proxy,
timeout=timeout,
ssl=False) as response:
j = await response.json()
Is it possible for await response.json() to raise a asyncio.TimeoutError exception?
(getting json takes too long, etc.)
Is twisted still the way to go if i want to learn to make a game server?
asyncio.wait_for(response.json(), time-to-wait)
import socket
import os
server= socket.socket()
server.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
server.bind(("0.0.0.0",8000))
server.listen()
while True:
cl,addr = server.accept()
print("Povezao se Klijent",addr)
zahtev = cl.recv(5000).decode()
metod,fajl,verzija = zahtev.splitlines()[0].split(" ")
fajl=fajl.lstrip("/")
print(metod,fajl,verzija)
if os.path.exists(fajl):
cl.send(b"HTTP/1.1 200 OK\r\nConnection: close \r\n\r\n")
cl.send(open(f"python web\it academy\{fajl}","rb").read())
else:
cl.send(b"HTTP/1.1 404 Not Found\r\nConnection: close \r\n\r\n")
cl.close()
why wont this work ?
when i type the file name /filename1 the website crashes
where are you typing the file name @ember ledge ?
i type the file name on google search bar
this is http socketing
thats because its not a web thing
cl.send() is gonna crash it cause you havent told it to display html or anything
i think at least
What was the problem
I changed half the code and directed the files directly
anyone have experience with Flask and SocketIO
what do you want help with?
So I wanna do a SSH port forwarding from localhost:8888 to 103.215.221.141:22 and the database on port 5432
How do I do that?
I did this but I got this error
thanks you for your valuable contribution
for what
error:error **Traceback (most recent call last): File "c:/Users/moon/Desktop/wifiwindowscracker.py", line 7, in <module> result = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles', i, 'key=clear']).decode("utf-8").split("\n") File "C:\Users\moon\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 411, in check_output **kwargs).stdout File "C:\Users\moon\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 512, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['netsh', 'wlan', 'show', 'profiles', 'NET=NET', 'key=clear']' returned non-zero exit status 1.**
hacking the passwords
of the routers
near
code
code:```py
import subprocess
data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode("utf-8").split("\n")
profiles = [i.split(":")[1][1:-1] for i in data if "All User Profile" in i]
for i in profiles:
result = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles', i, 'key=clear']).decode("utf-8").split("\n")
result = [b.split(":")[1][1:-1] for b in result if "Key Content" in b]
try:
print("{:<30} | {:<}".format(i, result[0]))
except IndexError:
print("{:<30}".format(i, ""))
can i get your help pls
anyone?
Any idea?
!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.
Is this your case?
https://www.ssh.com/academy/ssh/tunneling/example#local-forwarding
SSH port forwarding/tunneling use cases and concrete examples. Client command, server configuration. Firewall considerations.
I wanna connect to my postgresql database that is on my vps using my local PC
Have you tried something like this? 
ssh -L 5432:localhost:5432 103.215.221.141
I'm on a windows
As far as I remember there was ssh command on Windows too
ssh.exe maybe
I am not using Windows for development purposes so I cannot do more
Thank you kindly
How can i close a connection to the server when i close my application? also when i want to restart my server socket it says theres already something listening on this ip and port. How can i close this aswell?
i thought about with py with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: but that didn't work
can some one help me in #help-bagel pls?
i'm not sure but s.close() should work
but how would i know to close it when the user exists the app? like if i alt f4 it doesnt disconnect
Hi all, I have a weird problem since a Windows updated yesterday. I run a python script as part of a Jenkins build. This python script is executed on a windows 10 machine and does a build and then tries to copy the executable to a Linux server using scp. I first try to create the directory on the linux side using ssh + mkdir.
I use
cmd = ssh user@server mkdir/path/to/copy/to
in
subprocess.run(cmd.split(' '),shell=True,cwd='.',timeout=300)
Till yesterday this worked just fine.
But since yesterday (Windows restarted after an update) the process just hangs here.
Before the issue and even now I see some weird characters in STDERR:
STDERR: mkdir: cannot create directory Γ’β¬Λca_os_binaries/191247Γ’β¬β’: File exists
This in itself had not caused any real issues in the past.
Any help in figuring out what is happening is greatly appreciated. How do I even start debugging this?
I tried paramiko and hit a wall because of some other issues... (would not load module). I can go back to that if it is very highly recommended. But I am curious if there is any way to see why the process hangs in this subprocess.run() command when executing ssh.
Did anyone work with Websockets before?
try:
#[...]
data = s.recv(1024)
#[...]
except ConnectionAbortedError:
s.close()
except OSError:
s.close()
@light zealot nah that wont work if the contexmanager doesn't work
try os.system() instead of subprocess.run()?
the fact that the error says File exists is supposed to mean that the directory (or file or smthng) already does exist on the server side
and is thats the same mkdir command youre using?
coz as i know theres supposed to a space between mkdir and the path
like in mkdir path/to/copy/to
while you've typed mkdir/path/to/copy
not sure if thats really the wrong command or smthng, but i'm dumb so try the first command too lol
I am trying to create a game with python and socket. Does anyone know how to create private lobbies?
i am thinking of something similar to skribbl.io
where you can enter a code and join a room
Yeah lol you can do it, i did pretty much the same thing as what you want just a few days ago, can explain in breif if you want me to
just tell me and I'd go off explaining everything, just dont want to do it unnecessarily
hi i need to bypass acces denied on this server using python is that possible+
Probably, but not sure if anyone can assist you on that here (rule 5)
lol
yeah that would be nice
thx so much
ye lmao my pleasure
so do you want to be able to have multiple lobbies running at the same time?
yeah
Oops. That was my typo on discord. I have the proper space in my subprocess command.
oh
and do you want to have a code to join the lobby?
yeah
Thought subprocess module superceded the os.system().. So I was sticking to subprocess module. I can try os.system().
so when it creates, it gives you a code, or you can join an existing if one of your friends tells you the code
lol @trim moth you're too popular around here
yeah, tryin would'nt hurt right?
lmao it's not like that lol
and how would your lobby begin start the game?
it's a video streaming service lol
as soon as you enter the room, it'll be a game in process
idk if that would work
Last night, I got the paramiko and scp modules to work for what I needed to get done. So, I have my setup working. I will try os.system() also, but that is not necessary right now.
I now want to figure out how to debug such an issue.. in case same thing happens in the future.
so as soon as a player enters the lobby the game should begin? it's not a multiplayer?
it's supposed to be a trading game, where like 5-10 players can buy and sell something.
the error, it says tile exists, does such a file already exist in there?
i thought it would be cool if the price was determined entirely by a small group of people
ooooh
i can implement a start button or something, but i don't think its too important
yeah, but there needs to be a trigger of sorts to start the game once a satisfactory number of players have joined
like i had the connection of the host in my streaming to start the stream once all the viewers joined
oh i see
lmao
Right. The file already exists. But that is not a fatal error. My problem is that my python script running on windows gets stuck at this point.
Before the windows update yesterday, I also got this error (File exists). But the python script on windows did not get stuck.
I don't think it has to do with the file exists error. Because I deleted the file and ran the script. It does not give the error, but gets stuck in the ssh command anyways..
if i had a start button, how would i do it?
yeyah, maybe the windows update has rest your firewall settings
what do you use for the fornt end of the game?
pygame
That's a helpful insight. I will check. Thanks @trim moth
lol my pleasure
lmao talking to two people at once is difficult
lol it's fine
so i have something in mind
as you accept client connections, add all those client sockets in a list to make things easier
each player would have a start button on his screen right?
so if there are 6 players in the game, and 1 of them clicks the start button, a flag should be sent to the server notifying it that this particular player has pressed the start button
and the game won't start till all the players click the start button
ohhh thats a good design
lol thanks
but how do you know which player is clicking the button
do you use a dictionary with their address?
form the socket you're receiving the flag
yeah, like keep a record of which cllient socket has sent the start flag
once all of them send, start the game
bai
boye lol π
thats sounding familiar π
!warn @zealous ruin Stop spamming. I just told you that we don't allow requests for paid work.
:incoming_envelope: :ok_hand: applied warning to @zealous ruin.
!warn @lofty bough
haha, is there any place you would recommend to ask?
You can use any freelance searching service.
Fiverr, upwork, or something specific to your location.
ah okay
pretty weird that this server doesn't allow it
I feel like there are a lot of devs that would love some freelance work
@zealous ruin It's a giant moderation burden. We'll have to deal with malicious projects, scams etc.
ah
id love some lol, fiverr never worked for me
resp = sock.receive()
AttributeError: 'str' object has no attribute 'receive'
Anyone got a solution?
sock is a str? should be something else?
Is there any other way of building a server other than socket
Not really. A TCP server needs to use sockets, and that's the normal kind of server. You can make other kinds that listen to pipes or shared memory instead of sockets, but that's unusual
whats the best way to start with networking ?
Make a basic chat program
which is best python network library
it's sock.recv() lol
that too considering sock is a socket object, since the error says that sock is a string
there's nothing like "the best" ig, just use whatever fits your purpose, there's the sockekt, urllib and http modules i know of
is there any good one for beginners u found easy
@lone edge sockets
try making a simple chat app using sockets to understand how to transfer data with them
once you know how to transfer data, you can trasfer any kind of data, video audio or any file the only thing that varies is the mechanics
check out the pins of this channel there's a bunch of cool stuff the person who made it must be cool as well
lol
Is the link local identifier in IPV6 (the part including and after % at the end) a solid part of the spec, or an informal thing that people use to disambiguate the possibility for same address being assigned on multiple interfaces?
yes, it's a scoped ipv6 address, but it doesn't have to be an interface
google ipv6 zone index
@lapis venture
looks like the issue I ran into was address for 3.9, but hasn't been in other versions https://bugs.python.org/issue34788
hi, i asked a question here a while back, and it kind of got swamped, would anyone care to have a look at it, please? π
that's a massive question
a bit like bill gates saying he wants to start a software company and asking if anyone knows how to write an operating system
your best bet is probably to read up in detail on how other cryptocurrencies manage the p2p nature of the implementation
but it's not that complicated, basically you need some way for nodes to communicate with each other, and a discovery system
the Chia cryptocurrency client is mostly written in Python I believe
https://github.com/Chia-Network/chia-blockchain @harsh osprey
thankyou sir!
having somewhere to start is a huge help!
What are the limitations of making a game or an app to use the "user as a server" technique/structure or the way you call it?
guys i have question
guys i have question
guys i have question
guys i have question
ok
Chill
is it possible to make a firewall with python for windows 10
It's called peer to peer and generally you dont want too much load on the client. Usually one client only keeps a connection with exactly only one other client.
So that means that I shouldn't have a p2p connection on for example, an online room of 4 ppl?
You obvisouly could if you want too, but the client that acts as a server needs to be aware of that there can be a lot of potential drain on the computer if he wants many people in the room. It depends on the architechture of your app after all
Kind of, but if you want to get the best out of your firewall you should maybe consider some low level language. You can also use some system commands to create sort of a firewall, in unix you can mess with the iptables for example.
How like architecture?
My app is a speedcubing timer, the only things i will only be sending is wether a client is inspecting the cube, solving it or any new message on the chat
If you dont want to rely on a central server then going with a p2p solution should be just fine.e. Note that in a p2p application you will need someway for the other clients to connect to the one client which acts as a server, that by passing their IP-address +/ port. Shouldnt really be much of a problem, once again - depends on what you want your application to be like
Do they have to open ports or is it enough by sharing the IP?
The clients need to have open ports in order to allow TCP / UDP connections through, which can be done by the firewall
I mean, i could use a server, but I want to have so everybody can make their own room with the people they want, not everybody using the app on the same room, and I don't have that much experience with servers yet
Ohhh so that's what happens when you allow an app through the firewall?
Then the OS allows data to get through the firewall and then to your program so you can deal with the data they way you want, this can sometimes lead to security issues
p2p is definitely the less user friendly solution, if you care about that
So is less user friendly because you have to share your IP with people and involves lots of security issues
Definitely gotta learn server things
everything on the network works with IPs
I know
You will have to share the IP with server, but other clients shouldnt know each other's
anyways, if you want to go with a client-server architecture you can start by looking into sockets perhaps, or websockets if you're writing some modern web application
You can sort each room as a key in a dictionary, and the value can be some data for that room, so you can wait to implement a database and keep everything in memory if thats easier
So for example: {roomid: 00001, clients: 5, usernames: ['Ricky, Lizard, AwesomeDude']} and so on
I suggest you finish that chat app tutorial you stumbled upon, learn some basic networking / socket api stuff, then create some design of your core server
yeah, and maybe a value which keeps all client's socket objects
note that a dictionary is key:value
https://www.youtube.com/watch?v=sopNW98CRag&t=1938s
This is the tutorial
In this video we learn how to build a simple Python chat with a graphical user interface.
βΎβΎβΎβΎβΎβΎβΎβΎβΎβΎβΎβΎβΎβΎβΎβΎβΎ
π Programming Books & Merch π
π» The Algorithm Bible Book: https://www.neuralnine.com/books/
π The Python Bible Book: https://www.neuralnine.com/books/
π Programming Merch: https://www.neuralnine.com/shop
π» Exclusive Content π»
π₯ Patreon: ...
{room_id: {'clients': [], ...} }
The only "problem" is that I'm building my app (gui) with a class, and he's not
Yeah and also gotta finish to learn some stuff i forgoy
you dont need to follow exactly like the tutorial, the important is to learn the key concepts so u can implement stuff yourself
Can someone tell me how do they give "IP ADDRESS" as an input when using the subprocess module. I'm trying to do it with str(ip) but the ip isn't float.
https://github.com/SATAN01/DogeChat You can have a look at this chat app I made recently, it might help
it follows [[room id,room passw],[clients]]]
Although ik understanding other's people's code can be tricky XD
doge chat π
Indeed, its tricky
Another thing, when you allow an app through the firewall, you open the ports only for that app or anything can use that port now?
Anyone can attempt to connect through that port, it's up to your app to validate the request. If your app is listening on that port then all requests from that port should go only to your app.
Ok, so say that to play Minecraft on servers i have to open my ports, so if somebody attempts to connect on that port, Minecraft is the one who would reject or accept the connection?
Yeah, in some cases the OS can also do some work (the firewall) but mainly it's up to the app who is listening on that port
yeah, if your app expects some data to be received through a port, but and your port is closed, your app will never receive the data since the os will block the flow of any kind of data
and yeah, about p2p networks, is there a way to get ports opened automatically?
like, the only obstacle for a p2p network being user-friendly is, them having to opening ports on their system, only if there was a way to automate that, one could use apps usingg p2p networks with ease
It's generally a rare use case where you make the client a server, but I think that if you create a socket server listening on some specific IP, at least on windows, then there might in some cases pop up a "windows alert dialog", and after a click, you allow the program to open the server.
hello guys im doing my software development & programing for HSC and we have a assessment task and i need help if someone the knows about my task i have 2 tasks but this networking algorithm i need help. This is the Task Outline:
The assessment includes implementation of two algorithms, one to be re-implemented with GUI, and one case study. Each algorithm is to be represented in pseudocode, implemented with a program using a simple text-based interface, verified by a set of test data that includes evidence of the expected and actual test result. One of the implemented algorithms is then required to be rebuilt using a proper GUI user interface.
XD
i read it twice and still did'nt understand what the actual questions are lol
yeah, i've seen that happening, but that's a huge dependancy for the app to rely on the os to open the ports for it
and still not sure if that happens everytime and will happen for every user
well still worth giving it a bunch of tries tho, i'll try running a server a bunch of times listening to different ports each time, that should verify it
Lol, nor i, they havent actually said the question, just the rules surrounding it lol
Is it possible to use a python object in c#? (I kinda know the answer already )
If not, what u suggest i use for sending data between server(python server) and client(c# client)?
HTTP Requests. Literally simple as that.
Im trying to build an object oriented chat application and im using socket, so i dont think http request would be any help in this case to be honest cause i need the connection to be kept alive. Im just searching for an easy way to send objects between python and c#, and if i dont find any,ill use json for it. Like web applications.
Ahh, my misunderstanding.
I would for sure go with JSON as it's something that's universal. You'll just need to stringify and parse it.
It might also be possible to create C-style structs on the Python side and send them
depends on what kind of objects you're sending
serialising to JSON and serialising would be the most extensible solution
is there a guide on how to use a docker container and a cloud provider to set up a basic infrastructure
I feel like that question might be better suited for the tools and devops channel, but I am also curious
sockets?
yep
i'm working with a friend on a streaming service whose gui is in unity/c# and the under the hood stuff is in python, so we plan to use the c# and python sockets to communicate some data around like, some data to shown on the gui which is fetched from the underlying python scripts
itβs probably gonna work as well lol
well your going to be streaming data like video data, but im going to be streaming objects, if i wanted to make a client with python, i could've used pickle to make a serialized binary out of it and send it over the network.
but im going to use c#
oh
In networking, the End-To-End principle is basically insuring that data gets from computer 1 to computer 2 with minimal intermediaries, and without modification or changing of the data being sent.
An example of something that hinders the end-to-end principle would be something like a Nat-Box, which receives incoming and outgoing data as an intermediary, potentially rewriting payload data and normalizing ports or obscure values.
This is pretty much correct right? Is there anything I'm misunderstanding or not elaborating on?
@ me if anyone has some feedback ^^
I don't think that data modification or reordering aren't allowed 
There are also can be many intermediate nodes and nobody counts them (you don't have a counter of visited nodes in UDP or IP protocols for example)
According to Wikipedia:
In networks designed according to this principle, application-specific features reside in the communicating end nodes of the network, rather than in intermediary nodes, such as gateways and routers, that exist to establish the network.
For me it means that retransmission and other features are hold by end nodes, not by intermediate ones
This is for an open-book & open internet question on my exam,
Internet technologies believe that this was a good idea?
Give an example of a technology that threatens (or violates) the End-to-End principle.
Explain why this technology threatens (or violates) the End-to-End principle.
When I said payload data, I meant the packet headers, my bad! But I was thinking that would be a pretty good example of a technology that harms the End-to-End principle
Whereas the positives of the End-to-End principle would be, well, getting data from point a to point b exactly as-is
Seems like a pretty textbook use-case for gRPC tbh
wdym textbook use-case and gRPG?
Streaming objects back and forth between clients and servers implemented in different languages/tech
gRPC is a specific product. RPC is the general tech
it was jist python sockets before, but then we decided to have a gui, and some specific gui elements needed realtime data like no of clients connected to the server, so we cam up with using what i just learnt to call, gRPC
thanks
welcome - g'luck
Yeah thanks, we'll need it
It's not too stressful. I've got a few prod services running although I actually use twirp (https://blog.twitch.tv/en/2018/01/16/twirp-a-sweet-new-rpc-framework-for-go-5f2febbf35f/) but it doesn't support streaming so you'd need to stick with gRPC I think
yeah lmao
well, we're not actually streaming the videos lol
it's just streaming file data and writing it to the host machine and play the same video off the data as the data is being recieved and written to the host
Yeah makes sense
lmao
was there a better way to stream?
like opening each frame of a video with cv and send the frame and show it
So video streaming is a whole different thing and I've not built anything that does it tbh
yeah, i do have a 30s buffer between starting the file transfer, just the method i'm using, transferring the video file and playing it while writing, and then deleting after it's played just creates the illusion of playing, while sending the indivisual frame seems more like actual streaming, and the part which is unclear to me is how to send the extracted frame to the clients through sockets
I would just use a HLS stream settup tbh
trying to do it via sockets adds all sorts of complexity rather than just something like Nginx + HLS
hmmm
i have no idea about Nginx and HLS
gotta enlighten myself on that any help will be apprecialted ||help me plssss||
I keep getting this error when I try to host my bot please help
im not sure if this is the right section, but I'm trying to find something that will allow me to play a video on tv's through either python or command line. i've only been able to play something using Kodi using UPnP/DLNA i guess. my end goal is a server hosted on a raspberry pi that plays videos over the network to multiple TV's.
i havent been able to find an elegant solution, nor actually play anything simply without Kodi so far.
any suggestions?
sorry guys I have a (maybe dumb) question:
If I need to make an app which has to be offline, run offline, never connect to the internet, and prevent internet from accessing to any of it's output, what happens if the computer is online? Would I need to set any particular function to be sure that the app is running like if it was on a offline computer?
Cant you just not use any thing that needs Internet? Or block the internet access of the app with firewall?
just make the app in such a way that it doesn't need internet to work lol, isn't it what a offline app is? "doesn't need internet to work", or to do what it's supposed to do
an android tv app that uses socket to connect to your raspberry pi server and the the raspberry pi broadcasts the video to all the connected clients
if that makes sense, seems kinda viable tho
I've overcome all the complexity there is to it by spending a lot of time on it lol
import socket
HOST = '0.0.0.0'
PORT = 65431
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
while True:
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if not data:
break
stringdata = data.decode()
print(stringdata)
print(len(stringdata))
print(stringdata == "red")
red
5
False
I want to check if the socket client sent a specific text, but I always get false even though I type red
The text we see is just red while the lenght of that strinf as it says is 5 and we know that the word "red" is 3 characters long
so i suspect there being some spaces or something around
Yeah I also tried .replace(" ", "") but that didn't work either
so try looking at the output of print(list(stringdata))
Oh I also tried replacing \n but there is also a \r
oh, why is there a newline after the word red in the output
Ok now its working thanks a lot
lol what was wrong lmao
Yeah
lol
What was going wrong?
['r', 'e', 'd', '\r', '\n']
lol noice
For people who want to establish connection between client and the server on different networks without setting up port forwarding
noice
Hi, Iβm looking for some python code/library that can be used with a console cable
Could anyone help?
I need to get outputs such as a vlans list etc, from a layer 2 Cisco switch
sorry im not good enoff to help
um but how do you send a message to all clients online
im trying to create a terminal texting thing
#!/usr/bin/python
import socket
import threading
import json
def main():
IPv4 = socket.gethostbyname(socket.gethostname())
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((IPv4, 5050))
server.listen()
print(f'Servers local ip: {IPv4}')
while True:
connection, ip_address = server.accept()
print(f"Connection was gotten from {ip_address}")
connection.send("You are now connected to the server!".encode())
user = connection.recv(1024).decode()
while True:
try:
message = connection.recv(1024).decode()
if message.lower() == "stop":
break
else:
print(f"{user}: {message}")
# Here i want to add a thing where i can send messages to each client.
except:
...
connection.send("Thank you for connecting!".encode())
connection.close()
if __name__ == '__main__':
main()
You can create a list and append different clients to it and then you can simply use a for loop to broadcast the message
clients = []
#[....]
def broadcast(msg):
for client in clients:
client.send(msg)
while True:
connection, ip_address = server.accept()
clients.append(connection)
if msg_recvied_from_client:
broadcast(msg)
lol
How do i stop windows service from answer to packets that comes into a specific port that the port is closed?
for example in linux i can use
"sudo iptables -A OUTPUT -p tcp --tcp-flags RST RST --sport 80 -j DROP"
to stop getting answer from the os
yo
yo
I have a question on port forwarding
Can you chain the ports ?
Like listening on 5000 which will redirect you to 7907 which will redirect you to 5468 and so on
Just wondering if it was possible
its kinda possible
#!/usr/bin/python
import socket
from threading import Thread
class main:
def __init__(self):
self.server = socket.socket()
self.host = "192.168.86.62"
def main(self):
self.server.connect((self.host, 5050))
print(self.server.recv(1024).decode())
self.user = (input("Give your self a name: ")).replace(' ', '')
(Thread(target = self.recive)).start()
(Thread(target = self.announce)).start()
self.server.close()
def recive(self):
while True:
try:
print(self.server.recv(1024).decode())
except:
...
def announce(self):
while True:
message = input(f"{self.user}: ")
self.server.send(f"{self.user}: {message}".encode())
if message.lower == "stop":
break
if __name__ == "__main__":
main().main()
OSError: [WinError 10038] An operation was attempted on something that is not a socket```
im not sure what i did wrong here, it was working previously but now its not working at all
also for some reason my server is only able to handle one client when i really want multiple clients being able to talk to each other
sorry if its a dumb question. im kinda new to sockets lol
HI
pls I need a hand
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
can someone help me in #help-cheese
show some code
I have a question.
Suppose I have a Vuejs (frontend) and a Django (backend) application. I want to deploy them on a single server, such that when I send request to http://example.com, I can reach the Vuejs server and when I send request to http://api.example.com, I can see the django server. Is this possible via Nginx?
If yes, how would I go about doing it? Can someone please show the relevant docs, since I don't know what to look for.
i really dont know but as i understand it a single page application is one thing and the server is another and i think is like react which runs as a spa
i think vue*
Actually I am using nuxtjs which is a server side framework. https://nuxtjs.org/
nice
so why are u using django
or is it like built on top
of django
that framework
no no
nuxtjs is the frontend. It consumes the django api
they are completely decoupled and independent
the other day i was applying for a job and saw nuxt.js and i thought it was next.js haha
thought prob a typo its highly unlikely something is named nuxt
if next exists
haha
but now i c
i have used both. id say django is much better
django comes with a lot of stuff out of the box. express doesnt
i will admit that I have not used backend js framework like adonis etc but i have never needed to
if i need a backend then django it is
no questions
Guys, is there a more active place to ask about networking-related questions. I have asked before without any luck, my question for anyone wondering. I have two raspberry pi's that are going to connected wireless using UDP. Pi A is connected to a temp sensor, and pi B has 2 LEDs connected. The requirement for this to work is that LED 1 has to turn on within 2 seconds after the measured temperature exceeds a pre-set threshold, LED 2 is turned on within 1s If temperature continues at the same level for more than 5s. My option is to choose a timed trigger or event trigger or lastly a mix solution. My first problem is to decide if I want the control system to be in A or B or have it in both, my explanation is that because it is a small system and pi A is constantly reading data from the temp, it should be the one controlling the pi B, but I might be wrong entirely, and it should be that both control the system to handle packet loss eventually. My second problem is I don't know what solution to pick from as I said before, it is a small system, and I don't see any benefit of going event over timed trigger and worse, why I should even consider a mixed solution at all. My reasoning for going a timed trigger solution is that it is easy to calculate and you know before hand when the data is going to be sent
i mean udp sound like the correct option
let me try to read again what u posted lol so long
need to parse that through
I dont know how to post text and make it look good. I could post in a code making it maybe more readable
just split it up into paragraphs
an event trigger
i would use
there is a design pattern for that
gimme a sec
the observer pattern
: )
i think that is the solution
sounds fun that project btw
@dusty blade so you are saying an event trigger is a good choice in a system like this, but what are the upside of going event over timed ?
is adonis like more sophisticated?
https://www.youtube.com/watch?v=_BpmfnqjgzQ watch this video
Video series on Design Patterns for Object Oriented Languages. This time we look at Observer Pattern.
βΊ The playlist
https://www.youtube.com/playlist?list=PLrhzvIcii6GNjpARdnO4ueTUAVR9eMBpc
βΊ Head First: Design Patterns
http://amazon.christopherokhravi.com?id=0596007124
βΊ Design Patterns: Elements of Reusable Object-Oriented Software
http://a...
here is concept
and the implementation
it is like the exact problem you have lol
and btw with that pattern you can implement it via tcp which reliable and the function will only get called when the threshold occurs
which is more reliable*
the approach you were onto was like a brute force approach
this is more elegant
@dusty blade sadly I cant use tcp, but lets say that I go with an event trigger where lets say that if the temp is over 40c it sends data, will it not be a problem if the temp stays at 40c?
the problem with udp is how are you going to be certain the data arrives
it does not come with a guarantee
yeah I know
like tcp
going to sue acknowledgment
and send until an ack arrives?
keep sending until an ack arrives?
that sounds good
yeah, but will the event trigger cause me a problem where it barrages the other system with data? I might be wrong but I did some testing in packet tracer and it just spammed the other pi, honestly that one of the reason to why I was thinking a timed trigger would work given that it is just pi A and B and ofc it would cause problems if there are many more Pi's connected as it would have to update all the other pi's even if the data is not relevant.
Not sure never used it. I've only heard that Adonis is to Javascript what Django is to python.
nope it wont happen
it will stop calling the method once the ack arrives
let me put it this way: the pi which is connected to the sensor will call the method notify subscribers once the temperature gets to a certain level
@dusty blade yeah ok,.do you know any benefit for using a mix of both in my system because I cant come up with anything on my own
and the only subscriber is the other pi
i mean i can help
whats your code
do u have a repo
I just have concepts in packet tracer, and no code on the pi's get, because I feel like it I need to design and then implement and I want to be sure that I am not missing anything before starting
i rly think were good to go with that idea
why did u say we cant use tcp btw?
is it like a framework were attached to?
or something?
the LED's are for testing
yeah you have to delete that system folder ah I dont remember the name
@dusty blade the project is like a group thing and one of them said that mix is the better solution because we use the best of the two
π° π΄
i mean to call the method every other time
its not a bad idea
bots methods will work
both
like keep the timer method as a safeguard
i guess it doesnt hurt
let me remember what he said: we read data from the sensor every time so the data is always updated and then there no reason to send that data if it is not relevant so we send first package and then every 1 min send the others or something like that
we read data from the sensor every time so the data is always updated and then there no reason to send that data if it is not relevant
this part i agree
but you only want to notify the other raspberry when a certain event occurs
so he can trigger whatever he wants
right?
in this case when the temperature reaches 40 degrees
the part that doesnt make sense to me is notifying raspberry b about something which is not relevant to the other raspberry
more like this if d>40 send package and then if above is true send the data every 1min
why every 1 min
cant u just do like
when data goes below 40
send the other event
like one event for 40 and up
and other event for 39 down
light on for 40 up
light off for 39 down
yeah, but the condition is that if the temp stays above 40c for more than 5s the other LED needs to be up within 1s of reading that data
remember we have a certainty the packages will arrive because rasp A will not stop calling the method until B acknowledges
and rasp a will call the method after the temp mantains at 40c for 5 seconds
and his reason for 1 min is that it takes around 1 min for change in the temp
it doesnt matter how much it take for the sensor to read the input
as soon as he gets the next read below 40 he will inform again
raspberry b
and if temp comes back up to 40 for 5 seconds he will inform again
raspberry b knows nothing except the last temperature
or in this case the last threshold
ok, so A sends the temp data to B, and then in A if the temp is still at 40c for more than 5s it sends another data to B to inform it right ?
it doesnt need to
because it is still at 40
if he has not received the other signal is because the temperature has not dropped below 40
as soon as A reads the output from the sensor below 40 it will inform B
oh like that
and will not stop informing until B ack
but how is it then a mix of the 2 solution to me this sounds more like a event trigger
so
we just came up with the optimal
we dont need the mix
we just need the event based
yeah, but I am with you
i mean it does not hurt
to implement the timer too
its 10 more lines of code
but its unnecesary
its like taking a shower twice
you only need to bath once to be clean
ok, so to sum it finally A have 2 mods when it is 40c send data and when it is below 40c send data. Using a mix where we first send data at 40c and then send data in intervals of 1 min if the trigger event is true is pointless because we achieve the same results without the timed trigger. correct ?
Rasp "A" reads the output from signal every x time and when event "z" occurs he will call the method to inform rasp "B" and if event "Y" occurs he will call the other method to inform rasp B
correct
it would not make sense to nag rasp b over and over if nothing has changed
before the last time
rasp b only wants to get notified when something new comes up
he does not care about old news
I dont know if this will be enough to convince him, because I said at first that timed trigger was a good solution and it turns out I wasnt right at all
but I will try
i mean the timed trigger works
but this is the pro solution
lol
if u go to a crypto platform and notice how the price change interactively
it is this exact implementation
literally
imagine if the website get barraged every x miliseconds
it would crash
and the user experience would be unpleasent
unpleasant
not to mention the data compsumption
consumption*
is timed trigger solutions only good if the data is changing every x min/sec constantly and is relevant or would you say that event is still better?
it does not matter how frequently the data changes
rasp b only cares about 2 events
above 39
and below 40
it is rasp a job to inform rasp b for those 2 events
it does not matter if rasp a is receiving output from the sensor every x time
the sensor's job is to emit signals every time the temperature changes
rasp a job is to inform rasp b on those 2 events
rasp b job is to emit light on event a and turn off on event b
yeah in my system this should be the proper way, now if we say in more general way event trigger takes more processing power on the local machine because it needs to do some calculation and determine if a change is made first and this is one of the drawbacks, but because the processing power is almost 0 it really doesn't matter. I am trying to as you see argue my point so that we can be on the same page and start working with the hardware ofc he can still disagree, but it is a lot easier to do the work if everyone agrees
there is no calculation whatsoever
the calculation is
2 if statements
besides you are on a raspberry pi those things are like modern computers
faster than the fastest 1990 computer in the world prob
yeah that my point
the drawbacks are null
both approaches will work and for that project the timer method works and will not break anything
but if u are doing it might as well do it the prooper way
yeah
it takes the same effort to do it one way or another
besides you guys will understand a design pattern
which is called the subscriber
it is literally everywhere
on products you use daily
will help you a ton to understand it
because this is only the concept
you will learn a lot by doing the actual implementation
super super clean and elegant way
if u guys decide to go down that approach and are in desperate need of help feel free to send me a dm
and i will gladly help
ty will do if we get stuck, but it shouldn't be a problem with the lengthy explanation you have provided ty again
yup np
the observer pattern
write it down if u get stuck you can google and see some code
to watch the implementation
the concept you already have it
that video was amazing that guy is super clear with everything ty for the channel
good night
what would the alternative way to port forwarding so I can view my camera even when i am outside the network?
what do youi have against port forwarding?
in this case make a server with a static ip in between which both devices can connect to to talk
ah i was thinking of some sort of like automatically setup of port forwarding for others
If I go with port forwarding I need to teach how to setup it in their router and I don't even know if it will work well
ah right, yeah what you probably need to do is create a server, this is what big home camera companies work
so the camera connects to server
the device connects to server
the server manages them speaking
so i still need to setup a cloud server
yeah i think thats the best way
def check_message(self):
while True:
for client in self.clients:
#add a time limit so it can iterate through the users faster and make sure there is no
message = client.recv(1024).decode()
if not message:
...
else:
print(message)
#Tools().announce(message)
im not really sure how to iterate through the clients faster and make sure the messages are comming constantly
like it waits for the other person to send their message then your message sends
eh?
i did'nt get the second one
it sends the message after hte other person sends a message
cause i kinda want to create like a terminal group chat kinda thing
yeah, ik
and im not sure how to do it, so i thought that would work
i read the chat above
ohh right im getting the messages but the problem is it you cant send two messages in a row without it clogging up
i sent ok ok twice
it sends the first one then waits for the other person to send something then says ok
oh
yeah thats the problem
i kinda want to create a timeout but idk how to do that with the time module
umm, i think it's not clear to me
ok
@trim moth im just trying to cehck if each client has sent a message or not. cause the delay of someone not sending a message is kinda annoying
and if they havent sent a message in like 0.5 seconds then it just skips over them in the iteration
@dry lotus you could start a thread for each client?
but you dont need to do that
tell me how is the architecture of the chat system in your mind
normally i wont imagine receiving data from each client in a chat room
ok so what i have is a thread where is constantly checks if someone has logged in and it also grabs their ipv4
yeah
yeah, the socket object