#networks

1 messages Β· Page 31 of 1

opaque nymph
#

Problem here was, that you used hard coded token, and you should use it from the /token function, so i was thinking it was that.

pure furnace
#

yeah i know, but token doesn't change regardless i think

#

what is the header name?

opaque nymph
pure furnace
#
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

opaque nymph
#

Then idk. Sorry. I never used this one nor auth Token on API XD

pure furnace
#

np, thanks for trying to help haha

opaque nymph
#

You are welcome πŸ˜„

fluid egret
#

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

late spindle
#

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?

clear bobcat
late spindle
#

But why 120 and not 0?

earnest roost
#

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

clear bobcat
late spindle
#

I see

#

Thanks

clear bobcat
earnest roost
clear bobcat
# earnest roost 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 pithink

rustic crane
#

[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?

wintry drift
#

@charred mesa I've removed your message as it's not on topic to this channel. Please ensure you stay on topic in future.

charred mesa
wintry drift
#

as per the channel name, networking. channel descriptions also goes into detail over allowed topics.

prisma cobalt
#

i think he meant what channel was best suited to his particular question Scragly

charred mesa
prisma cobalt
#

πŸ‘

crimson oxide
#

Does anyone work with raw sockets?

clear bobcat
clear rock
#

i do

ember ledge
#

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.

analog zenith
#

Hey guys, do I need any sort of prerequisite knowledge to start learning networking? or is basic programming knowledge good enough?

light zealot
prisma cobalt
prisma cobalt
prisma cobalt
atomic plinth
#

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??

trim moth
# ember ledge Is there any steps to securing a server socket allowing connections from anyone ...

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

trim moth
trim moth
light zealot
trim moth
#

!e

import sockets
errant bayBOT
#

@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'
trim moth
#

!e

import socket
light zealot
trim moth
#

lmao happens

ruby radish
#

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)
        ```
#

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

flat rain
#
</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

ember ledge
#

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

prisma cobalt
#

CHECK THE PINS

#

third time now

ember ledge
#

where

ember ledge
prisma cobalt
#

what device are you on sorry?

ember ledge
#

chair

ember ledge
prisma cobalt
#

🀦 do you want to know how to do this or not

ember ledge
#

what to pin or the code

prisma cobalt
#

no, you dont know how to access pins, are you on a computer or a mobile device?

ember ledge
#

yeah I know

prisma cobalt
#

you know how to access pins?

#

theres an example chat on there

ember ledge
prisma cobalt
ember ledge
#

Thnx a lot

light zealot
zinc crag
#

lmao

leaden dagger
#

πŸ’€

trim moth
#

lol

crimson oxide
#

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

ivory rampart
#

Ethernet frame on WiFi thonk

crimson oxide
#

?

rustic crane
#

[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?

whole prawn
#

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}

sly gust
#

Hey can someone please help me with the shoppy API pleasee, ive been struggling for quite some time now

trim moth
#

lol

bright summit
#

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.

rustic crane
ember ledge
#

Anyone prefer me any pdf networking tutorial?
and also networking modules(except socket) pls

trim moth
trim moth
#

lol

#

sockets are cool tho lol

ruby radish
#

anyone know how to fix

#

this is code

iron fjord
#

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
prisma cobalt
#

also is clients a list of sockets?

iron fjord
prisma cobalt
#

okay remove the .encode(FORMAT) then

iron fjord
#

oh its meant to be decode

#

or do i need to put anything?

prisma cobalt
#

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}")
iron fjord
#

but this still doesnt seem to fix it

iron fjord
prisma cobalt
#

show me what clients is if your getting an error

iron fjord
#

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?

iron fjord
#

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

prisma cobalt
#

πŸ‘

ruby radish
#

i dont get whats going on

prisma cobalt
#

looks like your recving a character not in the utf-8 character set

trim moth
#

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

sterile kindle
#

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?

whole prawn
tawdry finch
#

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

trim moth
#

no it can't

ember ledge
#

does a proxy hide ipv4?

#

when packets are sent to a server?

clear bobcat
ember ledge
#

ahhh k

#

ty

tawdry moss
#

new to this channel

trim moth
#

Welcome

tawdry finch
trim moth
#

lol

tough dagger
# ruby radish i dont get whats going on

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

ruby radish
#

Oh I have it working now

#

Thank you

wide path
#

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.

bright tendon
#

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.

west mountain
#

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.

wide path
#

can anyone tell me if I am correct or incorrect

ember ledge
#
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?

whole prawn
#

"[+] 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()

hallow vine
#

@west mountain muli-line and not?

west mountain
hallow vine
#

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 '/'.
west mountain
#

I don't understand if there's any important difference between using %20 and +

ember ledge
#

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?

wide path
#

could anyone look at my question ?

gloomy root
gloomy root
#

Overall interval based sending would make the load more predictable yes

ember ledge
#

Hmm, what are the alternatives for doing it? I figure a proxy would work, but perhaps there is an easier way

gloomy root
#

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

ember ledge
#

Okay, thanks πŸ™‚

ruby radish
#

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.

tough dagger
# wide path can anyone tell me if I am correct or incorrect

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.

gloomy root
ruby radish
#

Ooooh

#

Got it

gloomy root
#

things like FPS video games etc... are udp based because you need speed but not reliability of data

tough dagger
#

Well with UDP basically you get port, and TCP adds sequencing and confirmation of receivement and pretty much that's it

gloomy root
#

UDP just doesnt have those round trips

#

meanwhile tcp:

tough dagger
#

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.

clear bobcat
tough dagger
#

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

tough dagger
clear bobcat
tough dagger
#

Nope

clear bobcat
#

When you have video conversation for example

tough dagger
#

If you want to receive and you never receive it is pointless

clear bobcat
#

When you lost some packets you don't care

#

You don't need to record whole conversation

tough dagger
#

I got your point but still you imply you get something at least

#

Which is why UDP alone plainly is often not enough

gloomy root
#

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

tough dagger
#

Well in theory reordering shouldn't happen that often

gloomy root
#

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

ruby radish
#

Anyone know this

prisma cobalt
ruby radish
#

uhhh

#

is there work proof

#

@prisma cobalt

#

this??/

#

idk

prisma cobalt
#

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

ruby radish
#

2000?

#

oh

#

wait its 1000

#

i think

#

???

#

how u get 2000

#

nvm

#

i get it

#

ty

static prawn
#

does anybody know any ports for NA-WEST server in Fortnite

#

If possible pls gimme port for NA-WEST in California

#

πŸ™

light zealot
sacred raptor
#

@ruby radish
data = conn.recv(1024).decode("UTF-8")
conn.send(data.encode("UTF-8"))

ruby radish
#

im good now haha ty

hexed glen
#
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

brisk basalt
#

hi,does anyone know about x-crsf-token?

hexed glen
storm saffron
#

Can't run it?

hexed glen
civic bay
#
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?

stone dirge
#

anyone know the reason for a '403 error'

gleaming ivy
#
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! πŸ™‚

storm saffron
#

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

neon kiln
#

how i can use threding ?

#

and i want login ssh port

raw field
#

@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.

ember ledge
#

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

ember ledge
#

Anyone here play with scapy? I'd hoped ^ would spark chatter

slim umbra
#

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?

burnt hearth
#

anyone dm me if you want me to tell you any exploitable vulnerabilities in your network

earnest lava
#

How can I reopen a websocket connection when it closes?

clear rock
#

any projects to make which involve networking?

pulsar bay
#

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?

tough dagger
# earnest lava How can I reopen a websocket connection when it closes?

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

still yarrow
#

I myself learned quite a bit by making my own HTTP client

clear rock
#

oh, what does a HTTP client mean exactly? i only know about raw sockets for now

still yarrow
clear rock
#

yes

#

so basically a program which can send and receive data?

#

like get and post requests

still yarrow
#

Yes

clear rock
#

oh

#

and what should i use to make it?

#

websockets?

still yarrow
#

and so basically it's sending a payload formatted like

GET / HTTP/1.1
Host: www.google.com

still yarrow
clear rock
#

epic, ill try

zinc cove
#

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

static fable
ember ledge
#

How can i update Exe files directly from visual studio code

prisma cobalt
idle portal
ember ledge
slim umbra
#

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

trim moth
split idol
#

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?

slim umbra
split idol
#

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

zinc cove
#

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.

slim umbra
errant bayBOT
#

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.

clear bobcat
#

!pypi nmap

errant bayBOT
clear bobcat
#

!pypi python-nmap

errant bayBOT
clear bobcat
lone edge
#

I want to learn python socket programming pls help

trim moth
lone edge
lone edge
trim moth
# lone edge pls help

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

lone edge
#

ok

trim moth
lone edge
#

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

trim moth
#

oh, websites, it could be a django website or something and take the text data and transfer to the clients using underlying sockets

deep nova
#

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?

ember ledge
#

multiple websocket connections?

ember ledge
#

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.

gloomy root
#

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

slim umbra
#

Guys just how secure is communication through sockets with untrusted users?

gloomy root
#

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...

slim umbra
#

and malware wise?

#

Can I be infected just by sending a message through a socket?

gloomy root
#

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

slim umbra
#

where can I learn to protect myself?

#

I mean then how can I make sure the data is what I want

gloomy root
#

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

slim umbra
#

Well I am just looking at the P2P system that bitcoin implements and how these guys are just openly communicating with random peers

gloomy root
#

well thats sorta an entirely diffrent system and setup

slim umbra
#

I mean I am recreating the communication myself in Python and my code is pretty bare

gloomy root
#

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

slim umbra
#

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

gloomy root
#

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

slim umbra
#

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..

slim umbra
#

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?

unreal depot
#

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!

harsh osprey
#

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)

ember ledge
#

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?

whole prawn
ember ledge
#

its weather info so why theres problem

whole prawn
#

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))

whole mural
#

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.

terse hill
#

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'

errant bayBOT
#

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.

clear bobcat
west mountain
#

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

clear bobcat
west mountain
clear bobcat
west mountain
#

Thanks for your help!

clear bobcat
terse hill
clear bobcat
terse hill
clear bobcat
#

Let see which keys are available

terse hill
# clear bobcat Hmm, how about `x.keys()`?

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

clear bobcat
terse hill
pale ledge
#
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.)

ember ledge
#

Is twisted still the way to go if i want to learn to make a game server?

placid fractal
ember ledge
#
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

prisma cobalt
#

where are you typing the file name @ember ledge ?

ember ledge
#

i type this

#

localhost:8000/file1.html

#

file1.html is the file name

ember ledge
#

this is http socketing

prisma cobalt
#

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

ember ledge
#

btw i fixed it

prisma cobalt
ember ledge
#

I changed half the code and directed the files directly

hushed dock
#

anyone have experience with Flask and SocketIO

trim moth
molten carbon
#

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

pulsar axle
#

proxies are for losers

#

use a vpn

prisma cobalt
#

thanks you for your valuable contribution

peak moon
#

guys

#

can i get help

azure lily
#

for what

peak moon
#

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.**

peak moon
#

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

peak moon
#

anyone?

clear bobcat
errant bayBOT
#

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.

clear bobcat
molten carbon
clear bobcat
clear bobcat
#

ssh.exe maybe

#

I am not using Windows for development purposes so I cannot do more

iron fjord
#

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

hollow musk
ember ledge
iron fjord
royal lance
#

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.

slow pumice
#

Did anyone work with Websockets before?

light zealot
slender steeple
#

@light zealot nah that wont work if the contexmanager doesn't work

trim moth
#

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

silk shuttle
#

I am trying to create a game with python and socket. Does anyone know how to create private lobbies?

#

where you can enter a code and join a room

trim moth
#

just tell me and I'd go off explaining everything, just dont want to do it unnecessarily

wild ferry
#

hi i need to bypass acces denied on this server using python is that possible+

narrow oak
#

Probably, but not sure if anyone can assist you on that here (rule 5)

trim moth
#

lol

silk shuttle
#

thx so much

trim moth
#

so do you want to be able to have multiple lobbies running at the same time?

silk shuttle
#

yeah

royal lance
trim moth
silk shuttle
#

yeah

royal lance
silk shuttle
#

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

trim moth
silk shuttle
#

hmm

#

what does your code do

trim moth
#

and how would your lobby begin start the game?

trim moth
silk shuttle
#

idk if that would work

royal lance
# trim moth lmao it's not like that lol

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.

trim moth
silk shuttle
#

it's supposed to be a trading game, where like 5-10 players can buy and sell something.

trim moth
silk shuttle
#

i thought it would be cool if the price was determined entirely by a small group of people

silk shuttle
#

i can implement a start button or something, but i don't think its too important

trim moth
#

yeah, but there needs to be a trigger of sorts to start the game once a satisfactory number of players have joined

silk shuttle
#

ok

#

i can do that

trim moth
#

like i had the connection of the host in my streaming to start the stream once all the viewers joined

silk shuttle
#

oh i see

trim moth
#

lmao

royal lance
# trim moth the error, it says tile exists, does such a file already exist in there?

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..

silk shuttle
#

if i had a start button, how would i do it?

trim moth
trim moth
silk shuttle
royal lance
silk shuttle
#

lmao talking to two people at once is difficult

trim moth
#

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

silk shuttle
#

ohhh thats a good design

trim moth
#

lol thanks

silk shuttle
#

but how do you know which player is clicking the button

#

do you use a dictionary with their address?

trim moth
#

form the socket you're receiving the flag

trim moth
#

once all of them send, start the game

silk shuttle
#

ok thanks

#

i got to go now for online school lol

trim moth
#

lol

#

cya

silk shuttle
#

bai

trim moth
#

boye lol πŸ˜‚

prisma cobalt
trim moth
#

lmao

#

i'm a sockets chad at this point lol

lofty bough
#

!warn @zealous ruin Stop spamming. I just told you that we don't allow requests for paid work.

errant bayBOT
#

:incoming_envelope: :ok_hand: applied warning to @zealous ruin.

zealous ruin
#

!warn @lofty bough

zealous ruin
lofty bough
#

Fiverr, upwork, or something specific to your location.

zealous ruin
#

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

lofty bough
#

@zealous ruin It's a giant moderation burden. We'll have to deal with malicious projects, scams etc.

zealous ruin
#

ah

prisma cobalt
ember ledge
#
    resp = sock.receive()
AttributeError: 'str' object has no attribute 'receive'
#

Anyone got a solution?

sturdy notch
formal oyster
#

Is there any other way of building a server other than socket

hoary sorrel
#

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

pearl rampart
#

whats the best way to start with networking ?

thorn stratus
#

Make a basic chat program

lone edge
#

which is best python network library

trim moth
#

that too considering sock is a socket object, since the error says that sock is a string

trim moth
lone edge
trim moth
#

@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

lapis venture
#

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?

frozen drum
#

yes, it's a scoped ipv6 address, but it doesn't have to be an interface

#

google ipv6 zone index

#

@lapis venture

lapis venture
harsh osprey
storm saffron
#

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

harsh osprey
#

having somewhere to start is a huge help!

magic phoenix
#

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?

crystal trellis
#

guys i have question

#

guys i have question

#

guys i have question

#

guys i have question

narrow oak
#

ok

magic phoenix
crystal trellis
#

is it possible to make a firewall with python for windows 10

narrow oak
magic phoenix
narrow oak
narrow oak
crystal trellis
#

@narrow oakhow to make it on windows

#

some module

magic phoenix
#

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

narrow oak
# magic phoenix How like architecture?

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

magic phoenix
narrow oak
#

The clients need to have open ports in order to allow TCP / UDP connections through, which can be done by the firewall

magic phoenix
magic phoenix
narrow oak
#

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

magic phoenix
#

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

gloomy root
#

everything on the network works with IPs

magic phoenix
#

I know

narrow oak
#

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

magic phoenix
#

I just went straight to a text chat app on python tutorial πŸ˜…

#

Where can i start?

magic phoenix
narrow oak
#

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

narrow oak
#

note that a dictionary is key:value

magic phoenix
#

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: ...

β–Ά Play video
narrow oak
#

{room_id: {'clients': [], ...} }

magic phoenix
#

The only "problem" is that I'm building my app (gui) with a class, and he's not

magic phoenix
narrow oak
magic phoenix
#

Ok ok

#

That tip does help

mighty iron
#

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.

light zealot
#

it follows [[room id,room passw],[clients]]]

#

Although ik understanding other's people's code can be tricky XD

trim moth
#

doge chat πŸ˜‚

magic phoenix
#

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?

narrow oak
magic phoenix
narrow oak
#

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

trim moth
#

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

trim moth
#

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

narrow oak
mossy dagger
#

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.

light zealot
trim moth
trim moth
#

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

prisma cobalt
trim moth
#

oh

#

lol

#

i thought is was blind lmao

hollow musk
#

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)?lemon_eyes

viral wasp
hollow musk
# viral wasp 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.

viral wasp
inland rampart
#

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

sullen breach
#

is there a guide on how to use a docker container and a cloud provider to set up a basic infrastructure

sacred plover
hollow musk
#

yep

trim moth
#

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

prisma cobalt
#

this it’s probably gonna work as well lol

hollow musk
#

but im going to use c#

trim moth
#

oh

broken steeple
#

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 ^^

clear bobcat
# broken steeple In networking, the End-To-End principle is basically insuring that data gets fro...

I don't think that data modification or reordering aren't allowed pithink
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

broken steeple
# clear bobcat I don't think that data modification or reordering aren't allowed <:pithink:6522...

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

whole prawn
trim moth
whole prawn
trim moth
#

ooh

#

didnt knew that theres a term for wjat were doing lmao

whole prawn
#

gRPC is a specific product. RPC is the general tech

trim moth
#

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

whole prawn
#

welcome - g'luck

trim moth
#

Yeah thanks, we'll need it

whole prawn
#

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

Twitch Blog

Today Twitch is releasing an RPC framework we use for communication between backend servers written in Go. It’s called Twirp, and it’s available now under an Apache 2 open source license.

trim moth
#

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

whole prawn
#

Yeah makes sense

trim moth
#

lmao

#

was there a better way to stream?

#

like opening each frame of a video with cv and send the frame and show it

whole prawn
#

So video streaming is a whole different thing and I've not built anything that does it tbh

gloomy root
#

Does it need to be low latency streaming?

#

or can it have a 30s buffer

trim moth
#

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

gloomy root
#

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

trim moth
#

hmmm

#

i have no idea about Nginx and HLS

#

gotta enlighten myself on that any help will be apprecialted ||help me plssss||

hollow plover
#

I keep getting this error when I try to host my bot please help

plain basin
#

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?

rapid garnet
#

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?

hollow musk
trim moth
trim moth
trim moth
gusty dawn
#
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

trim moth
#

so i suspect there being some spaces or something around

gusty dawn
#

Yeah I also tried .replace(" ", "") but that didn't work either

trim moth
#

so try looking at the output of print(list(stringdata))

gusty dawn
#

Oh I also tried replacing \n but there is also a \r

trim moth
#

oh, why is there a newline after the word red in the output

trim moth
#

try .strip()

gusty dawn
#

Ok now its working thanks a lot

trim moth
#

lol what was wrong lmao

gusty dawn
#

Yeah

trim moth
#

lol

trim moth
gusty dawn
trim moth
#

lol noice

light zealot
#

https://stackoverflow.com/questions/67596766/how-could-we-establish-connection-between-server-and-client-through-socket-progr/67597468#67597468

For people who want to establish connection between client and the server on different networks without setting up port forwarding

trim moth
#

noice

radiant vortex
#

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

dry lotus
#

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()
light zealot
dry lotus
#

oh right that works

#

ty

light zealot
#

πŸ‘

#

🀦

dry lotus
#

lol

restive tapir
#

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

naive dragon
#

yo

trim moth
#

yo

whole rapids
#

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

prisma cobalt
dry lotus
#
#!/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

simple geyser
#

HI

#

pls I need a hand

#

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

sullen breach
gloomy forum
#

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.

dusty blade
# gloomy forum show some code

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*

gloomy forum
dusty blade
#

ohh

#

server side rendering

#

its like django and next.js?

gloomy forum
#

yes

#

nuxt is to vue what next is to react

dusty blade
#

nice

#

so why are u using django

#

or is it like built on top

#

of django

#

that framework

gloomy forum
#

no no

dusty blade
#

ohh its nodejs

#

lol

gloomy forum
#

nuxtjs is the frontend. It consumes the django api

#

they are completely decoupled and independent

dusty blade
#

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

gloomy forum
#

haha

dusty blade
#

but now i c

gloomy forum
#

it exists very much

#

and its really cool too

dusty blade
#

btw how is django vs nodejs

#

for pure backend

#

ive just used nodejs express

gloomy forum
#

i have used both. id say django is much better

dusty blade
#

really?

#

why

gloomy forum
#

but its personal opinion really

#

i for one like python much more than js

dusty blade
#

yea me 2

#

but i know js so well

gloomy forum
#

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

wide path
#

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

dusty blade
#

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

wide path
#

I dont know how to post text and make it look good. I could post in a code making it maybe more readable

gloomy forum
#

just split it up into paragraphs

dusty blade
#

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

wide path
#

@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 ?

dusty blade
dusty blade
# wide path <@!826882273915174932> so you are saying an event trigger is a good choice in a ...

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...

β–Ά Play video
#

here is concept

#

and the implementation

#

it is like the exact problem you have lol

dusty blade
#

which is more reliable*

#

the approach you were onto was like a brute force approach

#

this is more elegant

wide path
#

@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?

dusty blade
#

the problem with udp is how are you going to be certain the data arrives

#

it does not come with a guarantee

wide path
#

yeah I know

dusty blade
#

like tcp

wide path
#

going to sue acknowledgment

dusty blade
#

and send until an ack arrives?

#

keep sending until an ack arrives?

#

that sounds good

wide path
#

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.

gloomy forum
dusty blade
#

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

wide path
#

@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

dusty blade
#

and the only subscriber is the other pi

#

i mean i can help

#

whats your code

#

do u have a repo

wide path
#

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

dusty blade
#

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?

wide path
#

the LED's are for testing

ember lance
#

Can I hack nasa using html

#

πŸ™

wide path
#

@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

ember lance
#

πŸ‡° πŸ‡΄

dusty blade
#

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

wide path
#

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

dusty blade
#

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

wide path
#

more like this if d>40 send package and then if above is true send the data every 1min

dusty blade
#

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

wide path
#

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

dusty blade
#

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

wide path
#

and his reason for 1 min is that it takes around 1 min for change in the temp

dusty blade
#

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

wide path
#

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 ?

dusty blade
#

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

wide path
#

oh like that

dusty blade
#

and will not stop informing until B ack

wide path
#

but how is it then a mix of the 2 solution to me this sounds more like a event trigger

dusty blade
#

so

#

we just came up with the optimal

#

we dont need the mix

#

we just need the event based

wide path
#

yeah, but I am with you

dusty blade
#

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

wide path
#

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 ?

dusty blade
#

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

dusty blade
#

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

wide path
#

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

dusty blade
#

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*

wide path
#

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?

dusty blade
#

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

wide path
#

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

dusty blade
#

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

wide path
#

yeah that my point

dusty blade
#

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

wide path
#

yeah

dusty blade
#

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

wide path
#

ty will do if we get stuck, but it shouldn't be a problem with the lengthy explanation you have provided ty again

dusty blade
#

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

wide path
#

that video was amazing that guy is super clear with everything ty for the channel

dusty blade
#

anytime glad to help

#

gnight!

wide path
#

good night

fossil pivot
#

what would the alternative way to port forwarding so I can view my camera even when i am outside the network?

prisma cobalt
#

in this case make a server with a static ip in between which both devices can connect to to talk

fossil pivot
#

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

prisma cobalt
#

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

fossil pivot
#

so i still need to setup a cloud server

prisma cobalt
#

yeah i think thats the best way

dry lotus
#
    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

trim moth
#

eh?

dry lotus
trim moth
#

i did'nt get the second one

dry lotus
#

it sends the message after hte other person sends a message

trim moth
#

you're receiving from every client

#

why would you do that?

dry lotus
#

cause i kinda want to create like a terminal group chat kinda thing

trim moth
#

yeah, ik

dry lotus
#

and im not sure how to do it, so i thought that would work

trim moth
#

i read the chat above

dry lotus
#

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

trim moth
#

oh

dry lotus
#

yeah thats the problem

#

i kinda want to create a timeout but idk how to do that with the time module

trim moth
#

umm, i think it's not clear to me

dry lotus
#

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

prisma cobalt
#

@dry lotus you could start a thread for each client?

trim moth
#

but you dont need to do that

dry lotus
#

if that explains it better

#

ok ig so

trim moth
#

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

dry lotus
#

ok so what i have is a thread where is constantly checks if someone has logged in and it also grabs their ipv4

trim moth
#

yeah

dry lotus
#

and stores it and stuff

#

the connection

trim moth
#

yeah, the socket object

dry lotus
#

yes

#

then i iterate through that to check if messages were sent

#

i should probably try creating a thread for each client like evorage said

trim moth
#

bruh. by architecture i did'nt mean this

#

like, server client interaction

dry lotus
#

you want the kode?

#

oh ok