#networks

1 messages · Page 42 of 1

ember ledge
#

i found something

#

to fix my problems

#

i did some digging

#

and research

#

and found an api in roblox from 2012 that doesnt ratelimit based on ip address

#

so

#

yeah

#

no need for proxies anymore

ember ledge
#

so now just simple questions

#

basically

#

b'HTTP/1.1 400 Bad request\r\nContent-length: 90\r\nCache-Control: no-cache\r\nConnection: close\r\nContent-Type: text/html'

#

im getting this

#

maybe i have this part wrong?

white sage
#

hi, do you know a library to do traversal nat ?

ember ledge
#

The get part isn’t a path because it gave me a 308 redirect

ember ledge
#

can someone give me a harder networking project ideea?

quick rapids
#

I want to create a wifi throttling tool

quick rapids
#

for example, block or limit certain devices on my wifi

ember ledge
#

thats ok

#

thx

quick rapids
#

can anyone give me some pointers on where to get started on this project

minor oriole
#

Hey, can anyone explain me how i can make a python file on an extern server and how i can connect to this and use a funcion that is in this file on the extern server?

quick rapids
#

is there a way to get device names as well as MAC addresses in python

minor oriole
#

you can use the command shell for that. Just import it and you can write and read in the cmd

ember ledge
#

as i told you before

#

GET https://www.example.com/path HTTP/1.1 will not work with regular websites

#

only with proxies (and as far as i remember some older version of HTTP, might be wrong on that)

#

No I understand that

#

@ember ledge

#

so obv

#

But when I use the normal path

#

400 error is returned

#

It redirects me to that

#

We went over that before

ember ledge
#

It’s like 308 permanently redirected to

#

That link

#

try changing

#

Host: roblox.com to

#

Host: www.roblox.com

ember ledge
ember ledge
#

Yeah

#

Looks good I guess though I don’t like the multi line string

ember ledge
#

@ember ledge left me on read

ember mica
#

A news report says that company XYZ’s network was attacked by outsiders, who apparently sent a lot of spoofed ARP requests/responses from remote machines to the company’s network, trying to launch ARP cache poisoning attacks. Please comment on whether this is fake news or not.
Can someone please explain this one?

ember ledge
ember ledge
#

I’m confused on the parameters

#

And also

#

That didn’t work

#

I didn’t just now try it since I’m not home but that was what I first tried

#

And it didn’t work

#

Gave me the redirect

#

I’ll try when home

ember ledge
#

@ember ledge

#

monkey moment

#

i fixed it

#

forgot to add content length

#

oooops lol

ember ledge
#

all good now?

ember ledge
ember ledge
haughty sinew
#

how can i invoke something when a websocket send anything using aiohttp

ember ledge
#

hey

ember ledge
#

like some sample code?

haughty sinew
#

i found the answer

ember ledge
#

@ember ledge i was wrong there is still something wrong

#

i cant seem to send my parameters through a get request in socket

#
              "Content-Type: text/html\r\n"
              # "X-CSRF-TOKEN: {}\r\n"
              # "cookie: {}\r\n"
              "content-length: 45\r\n"
              "\r\n"
              "assetTypeId=8&itemsPerPage=10&userId=31797661\r\n"
              "\r\n"```
#

i cut out the top line

ember ledge
#

alright

#

well

#

again

#

im dumb as shit

#

theres no need to put 9in the body

#

i just put it in the headers

#

nono

#

i mean

#

in the path

ember ledge
shell glacier
ember ledge
shell glacier
tacit matrix
#

Heya, so I have 2 4gs wireless network hubs, from 2 diffrent network supplier

#

What would happen if I plug them both into a network switch?

#

Anyone know?

kindred flame
# tacit matrix What would happen if I plug them both into a network switch?

It'd work. "Hubs" (what I am assuming are wireless routers) need to be configured each manually though. I would really recommend not using two different vendors as it can be difficult to manage authentication. Its usually much better to have a single hub (or even better: a router that uses APs instead of integrated for wireless) that connects to multiple APs if you want to expand your range.

Generally you want Router > Switch > APs

tacit matrix
#

I do have routers and aps actually In here

#

it goes 4G modem > Switch > ap

#

but here is the thing, i have 2 4g modems

#

that i wanna connect to the switch

#

and later in the future, i wanna connect a fibermodem into the switch aswell

#

(we dont have fiber yet in this old house from the 1960)

#

here is what my network is looking like atm

#

here is what i wanna do

#

@kindred flame

#

(if you are wondering why i have two routers conected in a series, i needed to isolate a projector in a meetingroom along with a printer so noone conecting from the AP's would be able to use the printer or projector for meseciues stuff, this was the only way i knew how without doing some weird stuff with the switch)

white sage
#

hi, i have a problem, when i download the package miniupnpc, i never get the files .py

rugged field
#

Hi @Марвил#2376

stark jolt
#

G'day everyone! I'm starting a networking company, specialising DDoS protection and web-filtering for educational services, (Schools for example).

I'm currently looking for someone to aid in the development of some backend softwares. There are no prerequisites, as this is a learning experience for whoever wants to join. Although there are no requirements, a history in networking and web development are desirable. To discuss this further, including payments, please message me privately.

Here are the current services we are developing:

Minecraft DDoS Protection:
  - Global network of distributed proxies, spreading the network of players across pools based on geolocation
  - We already have the knowledge and resources to make a fully functional API and web panel.

Content Filtering:
  - In the near future, we are looking at creating an educational tool, used to block certain websites that meet            
    certain filters. We have an idea on how this would work, we just need to put it into code and do some testing. On   
    top of this, the system will allow data allocation to specific accounts, have a live feed of tx/rx traffic, and 
    indicating whether is has been dropped or not.

HTTP/1/1.1/2 DDoS protection:
  - Similarly to the Minecraft DDoS protection, we are looking at supplying protection to web-applications, such as 
    websites, APIs and countless other web resources

Hope to hear from you soon!

Mitch

amber flint
#

i may sound like the you got any games on your phone? when i say this but.
How does a public server work and how is it possible to make my home laptop a server?

warm valley
#

Better not to open ports on your personal machine freely.

kindred flame
kindred flame
amber flint
kindred flame
prisma cobalt
#

people usually get stuck on the second thing lol

tacit matrix
#

I just want better 4g cover in the house

#

It's a pretty big place

#

The only modem is a shotty 4g modem

kindred flame
#

I mean no you can't just hook up modems and have them act as access points, since the only way thats possible is if it was a modem/router combo. A modem connects you to the internet, you have to have a router to route through a modem.

tacit matrix
#

I don't want to use them as wireless hubs! x3

kindred flame
#

fixed that

tacit matrix
#

Nor access points

#

I that's not how I want this to work

#

Did you see my map?

kindred flame
#

yes I am aware. I don't know if you understand all the terminology. AP = wireless access point, aka transmits 4g/5g, router = routes between devices, modem = connects from your coax or fibre to your home network.

tacit matrix
#

I don't have fibre yet

kindred flame
#

thats fine

tacit matrix
#

I have a 4g mobile phone modem

#

So

#

4gmobile phone modem is the only internet sauce

#

It connects to a switch

#

That to a few diffrent routers in the house

kindred flame
#

Okay why do you need 2 modems for 4g again?

tacit matrix
#

Better cover and if one fail i have a backup

#

The 4g isn't very reliablf

kindred flame
#

Okay I was confused I thought you were talking about 4g wireless and not connecting to a cellular 4g connection

#

so with that cleared up: If the two devices are the same brand, odds are they have a way to pair the devices so they can have better coverage. Two different brands and you will most likely have to manually configure the devices.

tacit matrix
#

No problems

#

My question is :what will the switch/routers do? Will they use both of og the modems, one. Both but switch between em?

kindred flame
#

So thats where the configuration comes in, if they are the same brand and you configure it correctly it will just swap when it needs to, using the best connection or when the other one goes out.

tacit matrix
#

And when I connect a fibre modem in the future, what will happen

kindred flame
#

It depends is it the same internet provider?

tacit matrix
#

Nooe

kindred flame
#

Then whats going to happen is that you'll be using two different IP addresses when the router routes your stuff out.

#

This can be bad if you are hosting stuff or certain brands that rely on having a singular IP might be not great. (Though assumably you won't need the other modems anymore if you are using fibre)

tacit matrix
#

Oh yeah

#

That's the problem im having with this 4g modem atm

#

It keeps changing the antenn it's connecting to. And changing the ip

#

I csnt have a static ip

kindred flame
#

I mean the provider should be giving you a static IP

#

Oh thats right, the sim card has to be a special kind that actually has a static IP on it

#

Most sim cards just use whatever is available first

#

They are called static sim cards or fixed IP sim cards

tacit matrix
#

I phones them about it. They said it's imposible since It changes thr antena depending on the connection

kindred flame
#

If thats what they told you then thats probably true

tacit matrix
#

So there is no way to ssh my raspbery pi :(

kindred flame
#

You could python code something to send out to your other PC the current IP regularly 🙂

#

unfortunately whenever it disconnects its gonna change IP though probably lol

#

Its not great, but thats what happens when you don't have a ethernet/fibre connection

tacit matrix
#

not sure if this clarifies it lol

#

and here is the plan for th efuture

ember ledge
#

@ember ledge no more errors?

ember ledge
#

But

#

Nothing I can’t fix

#

Yeah everything is working

random trout
#

interesting... i'm actually reading an article on sockets from realpython. the problem is i don't think it's possible for me to upload scripts to the camera - is that what you meant with "the other side"?

light elm
#

What would be the best way to send some text between a nodejs app and a python app?

#

I am thinking about sockets

#

basically the nodejs app would send some data and the python app would parse and do some stuff with it then return some other data which would then be used in the nodejs app

#

Are sockets the best method for this?

#

or like some http rest api like thingy with flask on localhost

#

that sounds overly complicated

late patio
#

How do i print the data in a flask server?

viral plume
#

How I can get the connection strength to the network I am connected to?

fast vale
ember ledge
#

can someone give me a socket-networking project in python pls?

earnest blaze
ember ledge
#

not games

#

cause idk pygame

earnest blaze
#

Did you already do anything?

ember ledge
#

chatroom and rat

#

I mean the basics

#

the most common projects

earnest blaze
thorn stratus
kindred flame
ember ledge
sharp dove
#

Can someone plsss tell me how to do step 4?

nimble maple
#

You create a CNAME record for the website/dns name

#

with the IP of the server

sharp dove
nimble maple
#

In the DNS server. Then with DHCP, you put the DNS server IP in the field

azure crypt
lean saddle
#

hello
I have a problem
in python code

#

print(gateway)```
this code return :
```   Default Gateway . . . . . . . . . : 192.168.0.1
0```
I want to delete 
``` Default Gateway . . . . . . . . . : ```
and return 
``` 192.168.0.1 ```
please help me
soft silo
#

if you want to get ip there's a better way

lean saddle
#

how

soft silo
#

socket.gethostbyname(socket.gethostname())

#

!d socket

errant bayBOT
#

Source code: Lib/socket.py

This module provides access to the BSD socket interface. It is available on all modern Unix systems, Windows, MacOS, and probably additional platforms.

Note

Some behavior may be platform dependent, since calls are made to the operating system socket APIs.

soft silo
#

stdlib no need for install

lean saddle
soft silo
#

hang on

#

socket.gethostbyname(socket.gethostname() + ".local")

#

it works on my linux

#

idk windows

#

but worth a try

lean saddle
#

my system is windows

soft silo
#

but do take a try

lean saddle
#

but it return my laptop ip

#

I want default gateway ip

soft silo
#

hmm

#

weird

#

idk sorry

wraith ice
#

awww packet tracer, i remember those days :3

half forge
#

I don't know of a good Python module for looking at your local routing table in a way I'd be "happy" with, so I think you are down to parsing system commands, which I'd always avoid if I could.

This Powershell command should return exactly what you want. The IPv4 default gateway. There normally only will be one, but in theory, there could be multiples.

Get-NetRoute -DestinationPrefix "0.0.0.0/0" | Select-Object -ExpandProperty "NextHop"

So something like

import subprocess
import ipaddress

response = subprocess.run(
    [
        "powershell",
        "-Command",
        "Get-NetRoute -DestinationPrefix '0.0.0.0/0' | Select-Object -ExpandProperty 'NextHop'"
    ],
    capture_output=True,
)

# WARNING: This assumes there is ONE and EXACTLY ONE default gateway.
# Broken networks may have zero, and this will crash.
# Some more complex network scenarios, including those with redundancy
# and those with VPN's may have more than one default gateway. This should
# also be handled.

gateway = ipaddress.ip_address(response.stdout.decode("utf-8").strip())
print(gateway)
ember ledge
#

Not sure if this the right channel to ask this, but basically I have these 2 services (Camera service: reads frames, processes data, notifies PLC service about events, sends data) and Programmable Logical Controller service (PLC service for short: reads data from PLC, notifies camera service about events) and I need bidirectional communication between these two services. My current implementation uses simple threads / queues for inter-thread-communication - however my code is starting to get messy and it seems I need to seperate these two services. I keep reading but can't understand which of the three I should be using: rabbitMQ, Kafka or Redis for such task ?

#

Any suggestions appreciated

radiant vortex
#

Hi, I am using netmiko to connect to real cisco switches/routers.
I am currently using time.sleep(0.1), ** Can I send commands to cisco devices instantly, or do I need the time.sleep?** if so, what amount should I wait in between each command?

loud linden
#

Hi,
Does anyone know of a maintained/decent library to you for interfacing with Cisco Nexus switches?

loud linden
#

is netmiko maintained?

loud linden
#

I am trying to write a small monitor for my PTP status which I want to send to Zabbix - i was wondering if anyone has any recommendations on how best to do this? I have many switches on different subnets

half forge
# radiant vortex Hi, I am using netmiko to connect to real cisco switches/routers. I am currently...

Generally, after using send_command() Paramiko will wait until it sees the prompt again before sending the next command, so you shouldn't need a delay.

You can do send_command(expect_string="SOMEREGEX") if you want to see something other than the prompt as the thing to wait for.

I've found prompt detection mostly "just works", but if you go into router contexts with unusual prompts and the like, you can find it breaks.

fleet sparrow
#

hello, how do i fix a 403 forbidden when trying to access a docker running on a server port

coarse leaf
#

I am so new to socket programming, i am making a chat application
Ques: if i am hosting on local network then to connect with others i need to have one port dedicated to all the person or i have to have one port for each person

ember ledge
#

You have to port forward, program your router to redirect incoming packets from a specific port to a specific ip:port in your LAN

#

Get the IP address of the computer you are using and make sure that packets coming to your router are redirected to the address of your computer and the port you open.

#

when i say your router i mean your WAN IP

#

you know the difference between WAN and LAN?

coarse leaf
#

😅 lan for local area network and wan for wolrd area network?

ember ledge
#

yes

#

all devices connected to your router are in LAN

coarse leaf
#

Is there any vidoe u will suggest me to watch ? I have just seens some tuts ob python socket, and i am working on local onkine chat app with the tech with tim code as the basic understanding

ember ledge
#

no, i didn't learn from youtube

#

sorry

coarse leaf
#

U learnt from ..?

ember ledge
#

There was a guy here on the server, I don't know his name anymore

#

But i also took some networking courses

#

He teached me how to do it

coarse leaf
#

Ohh

#

Are lan and wam two different things in terms of device?

ember ledge
#

they are not devices

#

LAN is a defining term

#

Define all devices connected to the same router in your home

#

WAN refers to all routers that are connected to the global Internet

coarse leaf
#

😂 i am mobile network user, 😅 and i have nothing connected to wifi

#

It seems like i must clear my basics 😅

#

Anyways thanks, seems like a next level thing for me to work on

long pelican
#

someone help, I made a code to check if the version of the program is the most up-to-date, in the case the code has a variable with its version and on the site it has the most up-to-date version, so my if is not working the way it was supposed to work even if the version that is in the var and the one on the site is the same it prints (version wrong) and if it is wrong it prints the same thing someone help pls

In vs code:

Versão_atual = "v1.2"

def teste333():
    Url = "https://Teste.pontoio.repl.co"
    conexao = urllib3.PoolManager()
    retorno = conexao.request('GET',Url)
    pagina = BeautifulSoup(retorno.data, 'html.parser')
    print(pagina.prettify())
    global versao
    versao = pagina.prettify()
    
teste333()
print(versao)
print(Versão_atual)

if versao == Versão_atual:
    print("version certain")
if versao != Versão_atual:
    print("version wrong")

In replit:

from flask import Flask
from threading import Thread

app = Flask('')


@app.route('/')
def home():
    return "v1.2" #versao atual da insim mais atualizada possivel


def run():
    app.run(host='0.0.0.0', port=8080)


def note():
    t = Thread(target=run)
    t.start()


note()```
meager wasp
#

what python modules should i learn for networking after sockets

storm saffron
#

returno.data is exactly what you want

#

but you're parsing it as html then displaying it as html again

nova maple
#

.

radiant vortex
#

not 100% sure though

short raven
#

is there any way where we can do reverse dns look up with multiple ip address?

coarse leaf
#

In many yt tutorials i see that on server side they do an infinite loop and then after work is done they just closes that program
Python handles all this at its side but how can i close the server while closing the program

#

When i see the tcp connection i see that thise connection (server and client) are still established, i tried to end the process throught powershell commad but it seems like they dont closes but their PID number changes

half forge
#

@coarse leaf

So reclarifying the question so I know I'm thinking about the correct thing.

  • You have a client program, and a server program.
  • You fire them up and they communicate successfully using TCP.
  • You terminate the server program (how exactly ?).
  • You say the connection is "still established". I'm guessing this is by running something like "netstat -an" and seeing "ESTABLISHED", but I'm not sure.

"I tried to send the process throught powershell commad but it seems like they dont closes but their PID number changes"

That sounds like whatever program you are running restarts on getting the terminate signal from Powershell, rather than actually terminating, but I'd need to know more about the server you are running to know that for sure - as well as exactly what you are doing with powershell.

coarse leaf
# half forge <@!779669942156263424> So reclarifying the question so I know I'm thinking abo...

I dont have any idea that what i am saying is how much correct, it has nothing to do with powershell, i was just asking that in lots of tuts we see that we have server running in infinite loop waiting to accept connection, and when we are done we close the program which it still seeking for someone to connect, python might be handling all these on exit or killing th program, but i thought thay anyway i can close tgat while loop before program ends

#

.
Currently im very new to socket peogramming, so i am just implementing what i have learned and by methid of trial and errors refining the knowledge and understanding 😅

#

Aah too long

#

Idk i should merge client and server things or not cuz i making chatt app and idl how to have connection for duel or multi person chat

half forge
#

That is a lot of code and I'm, still not sure exactly what you are doing. Might be better to put it up on github or something if you want people to be able to read the whole thing.

#

@short raven Not sure if this is the question or not, but if you want to have some Python code that sweeps an address range for reverse lookups, you might want something like this :-

import ipaddress
import pprint
import socket

# Nonexistant DNS servers cause timeouts.
# If I was doing this at scale, I'd want async code.
socket.setdefaulttimeout(1)

def reverse_lookup_range_v4(iprange: ipaddress.IPv4Network) -> dict[ipaddress.IPv4Address, str]:
    resp = {}
    for ipaddr in iprange:
        try:
            resp[ipaddr] = socket.gethostbyaddr(str(ipaddr))[0]
        except socket.herror:
            resp[ipaddr] = False
    return resp

def main():
    lookups = reverse_lookup_range_v4(ipaddress.IPv4Network("195.66.226.80/29"))
    pprint.pprint(lookups)

if __name__ == '__main__':
    main()
#

This returns the following, which might be what you want ?

{IPv4Address('195.66.226.80'): 'lx.borwood.net',
 IPv4Address('195.66.226.81'): False,
 IPv4Address('195.66.226.82'): 'linx.vqbn.com',
 IPv4Address('195.66.226.83'): 'ge-02-tfm140-q05-bor01.tfm140.synety.net',
 IPv4Address('195.66.226.84'): False,
 IPv4Address('195.66.226.85'): False,
 IPv4Address('195.66.226.86'): 'lan.probe-edge5-thn-lon1.linx.net',
 IPv4Address('195.66.226.87'): False}
ember ledge
#

can anyone tell me what threading module is in python?

fringe aurora
# ember ledge can anyone tell me what threading module is in python?

threading is a module which lets ur program do multiple things at once, without the threading module u can imagine ur code as a single car moving from left to right, but when using threading u can imagine it as somewhat like, multiple cars moving from left to right, another example, without threading u can only have a single while loop running in ur code at a time, with threading u can have multiple while loops running at the same time

#

hope i did a somewhat reasonable explanation of what it is

ember ledge
fringe aurora
#

yep

ember ledge
#

also

fringe aurora
#

thats what it essentially is

#

yea ?

ember ledge
#

when I am learning new modules should I write functions of such as SOCKET
there can be really big list of them
And some will be good for revision or reference?
Written NOTES I meant

fringe aurora
#

sorry im not so sure what u mean, im somewhat of a beginner, i just happened to know what threading is 💀

#

apologies

ember ledge
#

haha

#

its simple

#

should I make written notes?

fringe aurora
#

ah well

ember ledge
#

of different modules

#

I learn

fringe aurora
#

u can if u want, it can be useful bc sometimes u may happen to forget smth, its a lot of information so forgetting things isnt that uncommon

#

im also writing notes sometimes i recommend it a lot tbh , can be hella useful

ember ledge
#

was just wondering people say its not efficient but written notes look good

fringe aurora
#

i would say its not efficient if u write too many notes, bc u know u cant rlly memorize everything, so writing every single thing u learn is a sort of a waste, maybe write the things which are more complicated/hard for u to understand so u can try to understand them from reading ur notes again and again

ember ledge
#

for example

fringe aurora
ember ledge
#

socket.gethostname()

#

its simply has two line defination

#

I can write it down quick

fringe aurora
#

yeya something liek that, quick notes yk

fringe aurora
ember ledge
#

I am not buying books for that

fringe aurora
#

xdd

#

nah but books can be hella useful too

#

especially for specific things like networking/automation shit like that, theres some specific books which are perfect imo

#

for learning specific things

ember ledge
#

maybe later lets see

#

thx and bye

fringe aurora
#

ofc, see ya

#

now imma write down my question

#

Using the SMTP library, is there any way for me to check if an email ive sent has been sent successfully, for example when using the requests library u can do things like
``import requests
x = link
response = requests.request("GET", x)
print(respnse)

Response [200]``
can i get something similar with the SMTP library ? when i send an email can i check if everything was received/sent without problems ?

#

thanks in advance

fringe aurora
#

@zealous flint yo ;-;

fringe aurora
fringe aurora
zealous flint
fringe aurora
#

any suggestions ?

#

apologies if its a dumb question

zealous flint
#

I haven’t worked with the smtp library before, so unfortunately no

fringe aurora
#

ah okay

#

no problems

zealous flint
#

Though it’s worth seeing if there are APIs to do this that way what you did with the requests library might be possible by observing the HTTP response code

brisk plover
#

hey I am making a project in which I need what ports are open on a website but it takes 3 min for me to check the ports, is there a fast to check ports in python currently I am using socket module

jaunty wasp
#

does anyone know why this payload is encoded? and how to decode? its surely not in base64

zealous flint
honest magnet
#

Is this community about networking with people, or web stuff

open isle
# honest magnet Is this community about networking with people, or web stuff

I think the word you're looking for is channel and not community? Community would refer to the whole server and maybe even its associated projects. Only this channel of the Python Discord server is designated for discussion on "Discussion on network protocols, technologies, hardware with relation to Python"

#

this is more for TCP, UDP, IP packets, DHCP and that kind stuff

#

and no, it's not a channel for meeting and making connections with new people, you can certainly do that in the server in general, but there's no dedicated place for it since well.. I think just participating and discussing on topic stuff is good enough at forming connections

honest magnet
#

Btw do you by any chance want to be friends or acuatence

open isle
#

I don't really answer questions on SO but I've done support work for programming communities (mostly as a maintainer of the black autoformatter) before so it comes somewhat naturally nowadays.

honest magnet
jaunty wasp
#

And encode back again

zealous flint
urban stump
#

Ah yes

#

TCP

#

How I do TCP

#

Plz assist

#

Jk

jaunty wasp
jaunty wasp
loud reef
#

Hi, I'm trying to use socket library to send RAW packets with their own headers. I trying to establish a three-way handshake with it. I already have sent the SYN packet but the server doesn't respond. In Wireshark I saw that packet arrived at the server, but it still doesn't want to establish the connection. Is there someone who knows how to help me?
I was wondering if it is because I use the wrong calculation of checksum, but I'm not sure about it.

pulsar hawk
#

Inserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM) socket.SOCK_STREAM means sending data via TCP, right?

coarse leaf
#

The question with woth context to python socket where server is listening forever i want that it should turn on or off as per my wish, like usih tkitner button to turn it on or off

earnest blaze
# coarse leaf

You'll have to delegate that to a different thread or process, and figure out how to forecefully kill it, altough who knows what complications if any may arise.
A much better option is to make the server async, and simply remove the server's socket from the monitoring list when you don't want to accept any more connections. But that'll require you restructure the whole thing from the ground up.

#

A simple yet reliable option will be to make the server socket nonblocking, and add the required exception handeling and flag checks.

coarse leaf
#

😓 well it seems like some adjustments has to be made, i wonder how the real life examples works or they might be too complex

meager wasp
#

What python modules do I learn for networking besides sockets

lusty storm
#

Hi i'm trying to do this but everytime i receive

raven wing
fringe aurora
#

im not quite sure what to make of this message tbh, somewhat confused

#

i understand what u are saying, hope theres a way to see if the email was sent correctly or not

#

if it threw an error each time the email couldnt be sent i could Just use try, except but as far as im concerned it doesnt throw any error

#

so im left guessing if the email was sent or not

#

i need to check if it was sent by going on Gmail.com and actually checking there

royal flame
#

I'm assuming you mean you have some sort of a home network and you want to expose your service listening on a port inside that network to the internet. In that case, the only IP address exposed to the internet is going to be your router. In order to get traffic to a service running on your computer inside the network, you need to configure port forwarding. Lots of routers have this available from their admin interface. So, you would configure say, port 8080 on your router to forward traffic to port 8080 to your internal network IP of your computer (say like 192.168.1.xxx). So out on the internet, a client would just connect to your router's IP at that port and all traffic would go to your computer.

fringe aurora
#

hope i get a response

coarse leaf
#

.
The nect question my mind raised that is this oky for program to do try excpet thingy inside an infinite loop?

storm saffron
#

it is but bear in mind it may lead to design patterns that are prone to just getting stuck if things break

#

e.g. say you try to perform an operation inside a try block and it's erroring in a way that will never fix, if you just except and handle the error every time it will keep going forever

coarse leaf
pulsar hawk
#

Let's say I have a server that receives data from clients in a separate thread. I want to send data from server to all clients at the same time, do I have to create another thread or it's not necessary?

coarse leaf
#

What ucan do is to store connection s and then use a for loop to send to all clients

pulsar hawk
rapid python
#

i had no clue where to put this

#

so whenever i make a google account i need a required id

#

i disabled cookies and also checked through the html and... idk it's nowhere to be found

#

i guess it's server side? here's some screenshots to help visualize

#

everytime a digit is appended to the front whenevr u run a request to googles api

#

anyone know how to find this number, or at least what it is so I can do more research because i can't find anything lmao

earnest blaze
#

But it should never be a problem

unreal sundial
#

Anyone have example code for Nat punch through for p2p that works? I can only find an MIT whitepaper and non-working examples on github

coarse leaf
#

Untill there isnt any other option

azure crypt
#

If AWS load balancer have 503 Service Temporarily Unavailable, can I redirect it to 3rd party url like github pages?

ember ledge
#

or the server it protects ?

azure crypt
merry pollen
#

Anyone interested in developing an advanced Restaurant POS using Tkinter?

atomic belfry
#

Hi, does anyone fancy helping me make the backend of this website https://www.subnet-calculator.com/subnet.php?net_class=A

Networking knowledge will be very beneficial. Would rather work on something in a duo // team rather than alone. Once we have backend setup we can make frontend if that is something someone is interested in (Either tkinter or Flask)

DM me if you are interested. I have some of the basics setup already.

OOP knowledge is required.

pulsar hawk
coarse leaf
ember ledge
azure crypt
silver field
#

What is socket programming?

slow gust
#

Hi guys.
I'd like to translate text in different languages, but want to keep the network traffic anonymous/ offline. Any ideas how to do that? For example push that trough tor etc.?

earnest blaze
final jackal
#

Anybody an iptables wiz here? I have an application where I need all outgoing traffic on a certain port to be routed to a different NIC

pulsar hawk
# silver field What is socket programming?

"A socket is a communications connection point (endpoint) that you can name and address in a network. Socket programming shows how to use socket APIs to establish communication links between remote and local processes." - Google

pulsar hawk
# silver field What is socket programming?

This is a basic introduction to the Internet protocols and how to use them in programs using sockets.

This is the first of two introduction videos on the Internet Protocol and its family of associated protocols (UDP, TCP, etc.) as well as Sockets, a pseudo-standard interface made for programmers to write programs which use these protocols.

The...

▶ Play video
coarse leaf
#

Are those losten and accept are connected in some way woth each other?

#

Can i close that listen cmd
If yes then will that affect accept method?

boreal canopy
#

does anyone have a list of us based proxies

copper smelt
#

What's a good project for Python networking?

plain trellis
#

Where I can find python for network security community?

echo wing
#

Where can I learn everything i need about the networking. I know some because i keep testing but still don't understand

kindred flame
echo wing
frosty knoll
#

In my opinion it depends on how you want to set your network up but IoT mostly comes with some kind of networking that you have to do, right?

subtle escarp
slow gust
subtle escarp
#

Here

#

I haven't personally used it yet, but I've got a good feeling it's pretty good considering its got 2k stars and its own GitHub account.

slow gust
#

thx :pepusclapo:

trim matrix
#

Hi guys, someone already installed owncloud in NAS Synology here ?

errant bayBOT
ember ledge
#

import math
import time
import turtle
#variables
name = input("whats your name")
age = int(input("whats your age"))
height = float(input("whats your height"))
weight = float(input("whats your weight"))
birthday = input("when is your birthday")

print("processing data...")
time.sleep(5)
print("Welcome"+name)
print("Your "+str(age)+" years old")
print("your "+str(height)+"ft")
print("your "+str(weight)+"lbs")
print("your birthday is on"+str(birthday))
#if statements
if age <= 18:
print("Note: your young")

elif age >= 18:
print("Note: your a adult")

if height <= 5.6:
print("Note: your short")

elif height >= 5.6:
print("Note: you are built for basketball")

if weight > 130:
print("Note: your god")

elif weight < 130:
print("Note: your a baby")

#

first project

chilly laurel
#

hey

#

i think my ISP blocking me from connecting to a proxy

#

dose someone have a solution

chilly laurel
#

funny

radiant vortex
#

Hi, i'm getting errors with Netmiko

#

the first one is
socket.timeout

#

and the second one is
netmiko.ssh_exception.NetmikoTimeoutException: Timed-out reading channel, data not available.

#

Could anyone please help me understand what they mean and how I can avoid them?

ember ledge
radiant vortex
#

I found out what’s causing the issue

#

But I have no way to fix it

#

So the command I was sending, was “interface range” and then it would use a list of all the ports

pale cradle
#

hi guys

radiant vortex
#

But, my switch has 1 x FastEthernet and 28 x GigabitEthernet

#

So because they are different types, the switch gives an error straight away

#

The only other option I saw was to go through the list and send 28 commands “int g1/0/1” “shutdown”

ember ledge
#

why not int range gi1/0/1-28

#

that should skip the Fa port

radiant vortex
#

The names of all the ports are obtained through the switch/router, I wouldn’t know what they are before hand

#

My program is Graphical user interface for Cisco IOS

#

So it has to be dynamic

ember ledge
radiant vortex
#

Oh yeah I use text fsm

ember ledge
#

that’s what i’m thinking, i have not had the chance to use it other than youtube guides and blogs

radiant vortex
#

Thanks for the suggestion, but if the device connected to only had FastEhternet interfaces it wouldn’t work 😦

#

This part all has to be automatic too 😦

ember ledge
#

well what i was thinking is a CSV file with the switch/router name or ip in one column. then the interface in the next column. then it’s possible to load the values and if the value matches Gi then use the int Gi command. if it has Fa then use the int Fa command.

#

i do something similar with a CSV with pandas. though it is for Meraki devices. if my meraki device name on the CSV file has AP in it. then i loop through all the rows with AP and configure them as i have to. if the name has SW for switch then that has its own set of commands

#

i haven’t tried something like this with netmiko so i’ll try it out on my spare time

radiant vortex
#

Ah I see

#

Thanks for the suggestion

opaque garnet
#

123

ember ledge
#

hello guys, i want to learn some networking stuff, i only find the socket module too hard.... is there another easier module with about the same possibilities???

whole prawn
#

You could always try aiohttp or requests to mess with rest apis

long cave
#

yeah

rustic crane
#

greetings, any idea how to find my router config website on Windows? when I type IP of default gateway, router config website does not show and address is not recognized. I tried nslookup by IP but didnt work (yes it works for domain name).
So how can I check domain name of 192.168.1.1 for example?

#

please ping / reply once someone got some clue, thank you

left jackal
#

i have a list of url to test if they are 404

#

how can i do that

#

just checking the response, but not fetching any resources of the webpage

ember ledge
#

I think you can do it with cURL

ember ledge
cunning tartan
#

How do i send a string over a socket?

#

i already have a connection using socket.connect_ex() (and socket.bind() on my server) and it first does a speedtest and then it tries to send a string with socket.send(stuff.encode()) but then when i do py data2 = conn.recv(1024).decode() print(data2)
it just returns a blank line for some reason?

#

'stuff' is just literally a string

cunning tartan
#

okay after a little 'investigation' it seems like the bytes are not being sent at all for some reason?

#

i have no idea why

cunning tartan
#

for some reason it sticks it to the end of the previous send message even though it is in its own parameter, is there a way to tell the server to end the message and start the next one?

#

all google tells me is how to handle multiple clients 🙃

cunning tartan
#

fixed the previous issue, it was stuck in a loop untill data ran out. Now the problem is that i have to break out the loop in another way than just py if not data: break
but i tried just doingpy #Client: s.send(b'e') #Server if data == b'e': breakBut if i do this e != e according to how the code runs? I tried decoding it before checking it as well but that also doesnt work

wind oriole
#

Is it uncommon to get "too many open files" errors when using aiohttp on linux? Would this vary by distro? I'm reading it's related to the number of available file descriptors, but I don't know what that # would have to be to support 100 semaphores

#

I ask about distro because I never had this issue on ubuntu but just got buried in errors in Debian

cunning tartan
#

does socket.send combine packets or something? Because for some reason when i do multiple sends it arrives as one

earnest blaze
# cunning tartan does socket.send combine packets or something? Because for some reason when i do...

Basically yes, Nagle's algorithm is a contributing factor, however even if you disable that the issue won't really be gone.
While yes Nagle's algorithm does buffer outgoing data if the last batch wasn't acked yet,
the problem is that you're reading an arbitrary amount of data with each recv call.
I can't stress enough how bad of an idea that is.
You can easily end up reading more than you actually want to, and you still have to deal with premature returns.
You can send a million bytes indivisually, then read them all at once.
There is no notion of packets on the level of the program TCP is serving (No ,tcp segments is another story)
Eitherway you can't guarantee when the data arrives and how fast your os and the actual recipient program will react to and handle it,
there are a lot of tiny factors you can't really control.
You're simply not supposed to use sockets like that without any real application protocol to circumvent these issues.
Anyway to fix the issue you can use headers of your own or go down the more painful path of termination characters and even more buffering.
With that said, I highly recommend these, for they will demistify the magical aspects.
https://www.youtube.com/watch?v=C7CpfL1p6y0
https://www.youtube.com/watch?v=kCuyS7ihr_E
https://beej.us/guide/bgnet/
And if you're intrested in what the hell it is that TCP is actually doing, you can't go wrong with the wikipedia page.
https://en.wikipedia.org/wiki/Transmission_Control_Protocol

keen ibex
#

can i make a proxy server with python?

normal gazelle
#

So I'm making a tcp chat server and im in the design phase at the moment for the protocol Im going to use. I want the server to only accept 1024 bytes and check message length, but the 1 issue Im having is packet fragmentation. Im not really sure how to handle this and what protocol to use to prevent errors from 3rd party streams etc

#

Im using asyncio so i cant just see if the the message is still sending aswell since Im awaiting on it. Im not sure what to do at this point as Ive tried many things

normal gazelle
modest barn
#

Can someone help me with try except please? I am trying to catch a TCP connection error using except ConnectionRefusedError: my understand is this way I can display custom message to the user, but instead I am getting a track back :

        except ConnectionRefusedError:
            print(f"\n{Fore.YELLOW}CODE HERE\n")
            continue

Traceback (most recent call last):
  File "C:\Users\cischology\AppData\Roaming\Python\Python39\site-packages\netmiko\base_conn
ection.py", line 1021, in establish_connection
    self.remote_conn_pre.connect(**ssh_connect_params)```
final meteor
#

Whats the difference between an ethernet address and an ip address?

ember ledge
#

Does anyone know of a good way to check the traffic of one single python script?

ember ledge
ember ledge
final meteor
#

Is it like a Mac address?

ember ledge
final meteor
#

So if ethernet uses MAC addresses to send data whats the point of ethernet addresses?

ember ledge
final meteor
#

What layer of the internet uses ethernet addresses?

ember ledge
errant bayBOT
#

Hey @ember ledge!

It looks like you tried to attach file type(s) that we do not allow (.pdf). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

ember ledge
#

Two good books for you

final meteor
#

Thanks!

soft silo
#

or maybe override the sys.excepthook (don't, do that as your last resort)

#

/shrug

modest barn
winged rune
#

who use sockets?

modest barn
#

Netmiko does 😀

lament sundial
#

I have a specific question that has to do with php SQL Server and python

#

Im want to setup a sql server in an enterprise server and not have to pay a service to do so. Do i need a service to send sql data through php to that server or do I not need to? And in addition to having the sql, im going to install the sql python connector. Would I need to use sockets to connect to the sql server or no?

ember ledge
#

If it’s a small project

lament sundial
#

Technically it's a small project but I have access to an enterprise server and want it to start growing

#

It's a school project

#

I just want to send data through ip address using php and don't know if I need a service to do so or if I don't

ember ledge
#

U don’t just to use php

lament sundial
#

Im sending data through html forms to the ip address for the sql server

ember ledge
#

Tbh I don’t rly know but I do know u don’t need to pay for php on ur own server

night helm
#

can someone help me with socket programing. Im making this chatroom and im trying to get the clients to communicate using defined functions instead of input

limber sparrow
#

hi, can anyone suggest me an library for audio transmitting over network other then portaudio based?

earnest blaze
night helm
night helm
little crest
#

Hi, I wanted to know how I can build a tool to download incoming video and audio streams using as few libraries as possible

finite berry
#

is there any apis for tts

tribal pewter
#

Is there a command like
journalctl | grep -Ei 'dhcp'
But to see ipv6 dhcp leases?

opaque gulch
#

Using a for loop to list through a list of data to Post to a website using s = session.requests(), but I've noticed that it seems to cache the data and somehow keeps sending the same exact data instead of the next one in the list. What can I do

upbeat spire
#

Hello everyone!

#

Can someone help me figure out how to a simple pay calculation

median prism
#

Can I see raw data packets through my OpenVPN

#

If so, how can I disable that

#

raw as in decrypted

merry abyss
#

You could try using a packet sniffer on your end, such as wireshark.

ember ledge
#

What’s the best way to mitigate a ddos attack on a 1gps home network? And I’m saying small ddos attack around 10gbps. Like what would I need to install/setup to prevent issues like these?

unreal wren
#

why would you be getting DDoSed

ember ledge
#

can someone help me im doing an auto update bootstrapper for my application, but how could i handle this if the files name are changed and but it will still find the files and replaces them?

(idk where to ask this question lol)

ember ledge
opaque gulch
ember ledge
#

if it still caches data, try a post request without a session

#

just requests.post

opaque gulch
#

ah could idea, I'll try that.

wary kayak
#

i'm trying to make a socket server work with also the webserver, i have the socket server on another thread, but when i try to push it to heroku doesn't seem to work as i expected

ember ledge
frozen drum
#

you mitigate it by never leaking your home ip to others, you can use something like cloudflare to proxy everything through their servers

sturdy yacht
#

We're making a chat app that works using http requests and mongodb (Server and Client)

#

Anyone would like to help

ember ledge
#

guys i wanna change my ip address every minute in opera gx, we can do it in Tor browser but can someone guide me step by step, i'd be reallly happy and it would make my day, please

inland sapphire
sturdy yacht
sturdy yacht
sturdy yacht
#

any good hosts for FastAPI webservers?

meager wasp
#

Guys

#

I Wana ask something

#

Python modules like scapu

#

What do I do to understand completely how they work

#

And how theyre coded

#

Where do I see the code?

final meteor
#

How does the third and second layer of the internet interact?

clever basin
#

could anything other than ufw be blocking connections? ( canocal ubuntu)

wind oriole
#

What would make a linux VPS start burying me in "Too many open files" errors after about 1000 requests with aiohttp when I'm not actually writing the responses to disk?

#

Would this be different on Debian vs. Ubuntu for any reason?

#

I worked very hard on this script and now it suddenly started erroring out

hushed cave
#

Hey everyone my name is Tony! I am a sophomore in college and am currently working on a social media/ NFT app. I am looking for potential programmers who might be interested in joining this project. This is a very ambitious project! DM me if you are interested.

ember ledge
#

Code:

@app.post("/register", dependencies=[Depends(_check_admin)])
@limiter.limit("5/minute")
async def register_user(
    request: Request, username: str, password: str, license_key: str
) -> dict:
    """
    [Admin]: Register a user with a license key.
    """

    # Find Profile
    exists = await user_db.find_one({"username": username})

    # Return Error if Exists
    if exists:
        return {"status": encrypt.text("This username already exists.")}

    # Check License
    license_key = license_key.upper()
    license_exists = await license_db.find_one({"license": license_key})

    # Return Error if License Invalid
    if not license_exists:
        return {"status": encrypt.text("Invalid license.")}

    # Proceed if all checkpoints are valid
    await license_db.delete_one({"license": license_key})
    await user_db.insert_one(
        {
            "username": username,
            "password": password,
            "hardware_id": None,
            "hwid_resets": 0,
            "note": None,
            "datecreated": date.today().strftime("%m/%d/%Y"),
        }
    )

    return {"status": encrypt.success()}```
#

Error:

    response = await func(*args, **kwargs)  # type: ignore
  File "/home/ubuntu/ascend-api/main.py", line 284, in register_user
    exists = await user_db.find_one({"username": username})
RuntimeError: Task <Task pending name='starlette.middleware.base.BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.coro' coro=<BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.coro() running at /home/ubuntu/ascend-api/env/lib/python3.8/site-packages/starlette/middleware/base.py:34> cb=[TaskGroup._spawn.<locals>.task_done() at /home/ubuntu/ascend-api/env/lib/python3.8/site-packages/anyio/_backends/_asyncio.py:629]> got Future <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.8/asyncio/futures.py:360]> attached to a different loop```
#

Any idea as to what could be causing this?

ember ledge
#

😭

radiant vortex
#

Hi guys

#

I have a very bad issue with my program ( I created it into an exe, that's when I got issues)

#

I am using Netmiko & TextFSM

#

I tried importing ntc-templates but it didn't help

#

**How do I set the environ variable and what do I set it to? Could someone please help me? **

#

any help is greatly appreciated

radiant vortex
#

Update: I think it fixed it... I sent an evrion variable and the new exe I made works fine 🙂

brittle loom
grizzled rain
#

hi

#

can i add python bot to my website??

ember ledge
sage otter
#

Hello there 🙂
Not sure this is the perfect place for that, but I need a little help on a request problem from a django app to fitbit API --> #help-rice

kind trellis
#

Hi, I'm a student looking for a Software Developer internship. I have experience in MERN, Flask and a bit of ML and automation with python. I'm looking for an internship in a product based company. My colleagues and friends are based in a service based company so I'm looking to cold email for referrals. I need some guidance to find people that are based in those companies and Is there a way to write eye catching emails including the subject that I can send to them?

dreamy crescent
#

Hello
I'm looking for help with getting free proxies with python api wrappers

#

Reply if you can help

#

Disclaimer: this is not for fishy purposes this is just because I am building a website and I want to test traffic management and how I can filter out bots using ML

river cedar
#

do routers act as a wireless acsess point for devices?

ember ledge
river cedar
crystal current
ebon reef
#

Can anyone suggest some books for networking

crystal current
crystal current
viral finch
#

Hello, I wrote a snake game in python and I want to move it to the web with html, how can I do it?

meager wasp
#

Python frameworks

#

Oh

#

Nvm

#

I read it wrong

full junco
#

Hi

#

does any body now mechanize libary

#

I want to learn it

cold charm
#

I want to host a simple flask api from my pc for short term. Tried to port forward and quickly realised that I am behind a NAT connection! So then I got to know about uPnP and was trying it out to expose my api through that but it doesn't seem to be working. I am on windows 10 and using UPnP Wizard to set-up port mapping. Have any knowledge about this then please help 😄

#

I am trying to connect to my api by requesting http://my_pub_ip(found on google search):port/

errant bayBOT
inner latch
#

anyone want to help me with a project I'm working on for my 10th grade computer science class? its not too hard I just don't quite understand it yet. dm for .py file

dark ravine
#

Hello, Guys Good day..
This is Kirankumar from India. Having 6+ years exp. in Networking.
I have started learning Python recently.. I wanted to know the Python for networking and python for data science or developers is different..
appreciate anyones guidance
Thank You in advance

ember ledge
dreamy crescent
ember ledge
#

Suppose i wanted to find HTTP(s) proxies without spending hours of research I can just make a google dork like the following:
“Proxy” “8080”

ionic zinc
#

please help me, how do I forward port 10010 from the locale to the global Internet?

ionic zinc
#

?

#

Can't I do it here?

ember ledge
#

Where?

ionic zinc
#

cmd

#

on a VPS?

ember ledge
dreamy crescent
ember ledge
#

@cold charm ngrok?

cold charm
#

I know about it, but i wanna learn and make UPnP work

lean saddle
#

hello

low hamlet
humble granite
#

hey guys! I'm trying to solve a CTF problem that requires me to send server ('localhost', 10000) GET_KEY to retrieve key and then to reverse the key and send it back to server to get a flag

#

Here is my code

#
import socket
def reverse(string):
  return string[::-1]


client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(('localhost', 10000))
client_socket.send('GET_KEY'.encode())
data = client_socket.recv(1024)
send = reverse(data)

client_socket.send(send)
#

but im not getting the flag, so my code is wrong somehow. Does anyone have a clue why?

real agate
#

can you connect a router to a router, without access to a router?

#

example: i’m going to a hotel which provides internet (via wifi), it doesn’t provide ethernet sockets

i want to take my own router and connect it to the hotel wifi, so that i can setup my smart home products like philips hue, etc

tough umbra
#

Guys on cidr/17 do we got here only 1 subnets? as all the ip addresses begin with the same 17 bits.

ember ledge
#

what is better? sockets or websockets?

frozen drum
#

they are different things :) websockets use sockets, they are based on http

shrewd plume
#

Code:

fast ore
#

i work for a financial org in the network security team but we have certain apps locked down, i can't install c++ build tools, but I want to use pytricia to ingest all our firewall/router routing tables, but i can't, is there a pure python version of pytricia?

frosty jetty
#

hi'

#

i am new '

#

somebody sent me a link of this server he told me you can learn coding is it true

ember ledge
ember ledge
#

atleast, we can help u with ur problems

#

programming problems ofc

molten geode
#

Hey,
As I found, many requests could be done by proxy, have you any experience ? Is this generally considered a safe ?

#

I mean for scraping eg.

lean saddle
#

hi

#

I have a problem in my app

unreal wren
#

Wow

vale reef
#

hi guys
i am trying to join discord servers from invite using discord tokens
it was working yesterday but now I can't access my main accounts since discord thought it was suspicious
and on this new account it's not working anymore
any fixes?

#

import string
import requests

def join(token, server_invite):
header = {"authorization": token}
r = requests.post("https://discord.com/api/v8/invites/{}".format(server_invite), headers=header)

discord token list

with open("discordTokens.txt", "r") as tf:
tokenIDs = tf.read().splitlines()

words = input("Invite: ")
words = words.translate(str.maketrans(string.punctuation, ' ' * len(string.punctuation))).replace(' ' * 4, ' ').replace(' ' * 3, ' ').replace(' ' * 2, ' ').strip().split()

print(words)

for word in list(words):
if 6 <= len(word) <= 8:
for i in range(len(tokenIDs)):
join(tokenIDs[i], word)
print("Attempting to join", word, "with discord token #", i + 1)

#

how do i join a discord server with python requests without discord blocking me / asking for captcha (even though I have a verified number + email +2fa set up)? thanks

dusk talon
#

x

ember ledge
#

@humble granite then you might need to receive the response again ||| print(client_socket.recv(1024).decode())

arctic hollow
#

How would i make a server for a multiplayer video game using sockets? I have already tried this and i keep having a problem where the client decides to stop sending data to the server

visual juniper
#

hi

ember ledge
#

Np

wise jungle
unborn thunder
#

hello! 🌻

storm osprey
#

Hello,
s.sendall(b"" + mainList[1] + '/' + mainList[2])
How to better write it?

valid schooner
dry geyser
#

or if those are already strings py "/".join(mainList).encode()

ember ledge
#

So basically

#

I'm trying to host a websocket database on linux

#

using python

#

but every time i try to connect

#

it

#

shows timeout error

random knoll
random knoll
ember ledge
#

Hi all, happy to have found this d-server. Since I am really stuck on a new school project I am working on. I am pretty new to programming, started my journey with Java 2020, and now since 2021 I code mainly with Python. Anyway, I am not sure if this is the correct channel for my question, but here goes...

I am trying to write a http/https proxy server to filter my web browsing. I have tried to find a good tutorial on Google and Youtube, do you guys have any experience with coding proxy servers and can help me or do you know any good way for me to start?

hollow sphinx
#

hey, does anyone here know if its possible to connect to a server on multiple ports on a pc ?

#

like can i have 3 different programs all connected to a server on port 443 for example

errant bayBOT
#

Hey @ember ledge!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

ember ledge
#

Can someone look and maybe tell how to implement HTTPS? this code works on HTTP

cloud spruce
# hollow sphinx hey, does anyone here know if its possible to connect to a server on multiple po...

No, you can only bind one process to one port at a time, unless you bind them to different addresses or one to * (asterisk/wildcard/all/any, sometimes denoted as 0.0.0.0), but if there is a binding for the specific address that is receiving the traffic it will have precedence and the wildcard binding will never get those packets.
If you want to do something like that you need a server process that can act as a reverse proxy and route (or rather proxy or forward) the traffic to the right destination or other process in some way according to rules that you give it.

cloud spruce
frozen drum
#

transparent HTTP proxies don't work for TLS/HTTPS - so you have to be content with proxying in the clear or not creating a transparent proxy (or proxy at the TCP layer)

ember ledge
#
import SimpleHTTPSServer
import urllib
PORT = 9012
class JustAProxy(SimpleHTTPSServer.SimpleWebSocketServer):
   def do_GET(self):
      url=self.path[1:]
      self.send_response(200)
      self.end_headers()
      self.copyfile(urllib.urlopen(url), self.wfile)
httpd = SimpleWebSocketServer.SimpleWebSocketServer('localhost',PORT,JustAProxy)
print ("Proxy Srever at" , str(PORT))
httpd.serveforever()```
cloud spruce
#

@ember ledge what is your ultimate end goal here, is it to learning how proxies work or for doing the filtering you first mentioned?
i'm asking since there are lots of software that can already do sort of what you are asking for depending on the situation and exact requirements you have

ember ledge
cloud spruce
ember ledge
cloud spruce
#

@ember ledge instead of just handling normal http "get", "push" and friends, your proxy also need to handle the "connect" method for the https requests

marble lance
#

Hello. I am trying my first time to edit a twitter spider script. There is a hidden.py that gives the user types his keys there. I need to input consumer_key, consumer_secret, token_key and token_secret but in twitter developer webpage i can just find 3

cloud spruce
marble lance
# marble lance

Do I have enough information to complete this dictionary? Thank you

ember ledge
small meadow
#

Not sure if this is the right channel but if it isn't please feel free to redirect me.

I'm trying to use the aiocometd module to subscribe to a cometd websocket. But I'm getting frequent connection drops with 402::session_unknown.

I suspect it's not sending the connect packet in time but I can't seem to find the segment of the code that allows me to send the connect packet ~3 seconds earlier. Would appreciate another set of eyes.

https://github.com/robertmrk/aiocometd

GitHub

CometD client for asyncio. Contribute to robertmrk/aiocometd development by creating an account on GitHub.

cloud spruce
# ember ledge https://paste.pythondiscord.com/ilakavexep

@ember ledge i had not looked at your code until now
a few things stand out to me

max_conn doesn't have to be that large (especially if you implement the next change i'm suggesting below) as it's just the connection queue for connections on the listening socket that has not been handled with .accept() yet

you probably want to move your first call of conn.recv() from the main() function as it executes in the main thread and it's a blocking io call, if you instead move that code into conn_string you don't need to pass it data and you'll also do the blocking io call to conn.recv() in the separate thread that is serving that connection, so that the main loop can concentrate on just accepting new connections and firing off new threads for the new connections

listen_port and max_conn doesn't have to be global and buffer_size probably shouldn't need to be as it can either be defined in your conn_string function or be passed in to it as an argument (maybe even with a default value so that it doesn't have to be passed in unless you want something else than the default) and then again to the proxy_server function in a similar manner

you could also read the port number that the server listen to using argparse and have a default value for that as well instead of interactively prompting the user for the port number when starting the proxy

i have only dissected your main() function you posted on that url, haven't really looked too closely at the logic in the other two functions

cloud spruce
trim moth
#

also @cloud spruce's changes make sense, use that

ember ledge
cloud spruce
#

@ember ledge your url/uri handling in conn_string could be improved and more robust by using urllib.parse https://docs.python.org/3/library/urllib.parse.html as well as the code would become shorter and easier to read

you also need to transform the data that you send() to the web server in proxy_server as the request from the browser to a proxy has the full url while a web server only expects the full path, without the protocol (http/https part), hostname and the optional port, just the first / and everything after it

there is really a lot to take in to consideration when implementing a http proxy, probably more than you want to take on, but even implementing a basic one that is not even near standards compliant is still a great learning experience
implementing the "connect" http method support for proxying TLS/SSL is really simple in comparison to proxying the rest of the http protocol that is not encrypted

if you are sill keen on implementing a http proxy your self, instead of just installing one (privoxy, tinyproxy, squid proxy, burp suite community edition or charles proxy to just name a few) and configuring it to do the filtering for you, you can check out https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol and the list of rfc standards, out of which i would recommend the now obsoleted RFC 2616 https://datatracker.ietf.org/doc/html/rfc2616 which stood the test of time for about 15 years (between 1999 and 2014) as a starting point and where the most relevant bits are contained in a single document and current browsers will still be compatible with it

neat wyvern
#

something for them

#

nevermind im all good

vagrant grove
#

Is there an easier way to restart app server process on python without having to do a

#

sudo lsof -i :<port> and kill -9 <pid> every time?

#

i'm using django

fast ore
#

hey all, looking for a pure python version of pytricia, has anyone looked into this?

ember ledge
fossil lodge
#

OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted

Does "normally permitted" mean I can allow more sockets to be used? I couldn't find anything about it online

ember ledge
#

it means a socket is already running on that port on that specific address

cloud spruce
frosty dome
#

Hey everyone, I am Rohan. I want to enhance my data analysis skills. Have knowledge of SQL, Excel, Tableau, Power BI and basics of python.
I am a 4th year undergrad, will be starting with python.
Anyone who is on the same level and want to move further in the field of data analysis and consulting, dm me.

fossil lodge
cloud spruce
fossil lodge
#

I found out u can see some traffic if you set packet type to RAW but I have to parse the packets my self

cloud spruce
# fossil lodge I found out u can see some traffic if you set packet type to RAW but I have to p...

yes, that is what it does when you sniff the patckets, you need the raw socket for that and the privileges on the machine to do so
and yes, that is the way to do it using only python standard libraries, then you also have to parse the packets your self
using scapy or any other such library will abstract much of that away for you and do the heavy lifting when it comes to parsing

there are other ways to sniff the traffic like using a driver or firewalling in the OS to send copies of the packets to another process or even using another device between the two computers that is talking to each other, but that is probably beyond the scope of this

fossil lodge
#

low level stuff always interesting 😜

cloud spruce
#

and also about where you are on the scale between doing the project to learn or if you just need to get a task done

ember ledge
#

what kind of machine can intercept internet traffic?

cedar forum
#

in what context

#

any router

ember ledge
#

I mean are eletromagnetic waves going through air

#

router have the exact specifications to do that

cedar forum
#

any device on a wifi network can intercept communications

#

open wifi network more so

#

any device along the path to the destination can also intercept

#

of course, HTTPS and encryption makes this harder

ember ledge
#

not at eletromagnetic waves level

cedar forum
#

uh

#

i'm not following what you are saying

ember ledge
#

no. im wrong

cedar forum
#

anything that can intercept 2.4GHz radio can intercept wifi, it needs a bit more than that to be able to do anything useful with it

#

like decoding 802.11

ember ledge
#

ohhh that's right

#

the way the hardware is built to avoid this should be interesting

cloud spruce
# ember ledge what kind of machine can intercept internet traffic?

@cedar forum has already mentioned routers, but there is a lot of other network equipment that the traffic may pass such as switches, firewalls and load balancers just to name a few, and then there is all the purpose built equipment like ethernet taps (for "copper" cabels) and optical spliters (for fiber cables) and packet brokers to just name a few in that category as well

ember ledge
cloud spruce
ember ledge
prisma cobalt
#

anyone know how virtual machines all share a single physical network adapter (im thinking in terms of mac addresses and ip's)
everything i looked up resulted in a tutorial for some software lol

prime notch
#

Have someone implemented UDP hole punching before?

marble lance
#

why we need to learn socket programming in python?
what's the application of those knowledge? thank you

cloud spruce
fossil lodge
marble lance
#

why XML and JSON are considered as "format" of web data?

we have pdf, image, plain text, csv.... etc.

When we surf the internet. All of the transmitted are bytes? or XML? or JSON?

Why people would say JSON / XML are the protocol of web data communication? thank you.

cloud spruce
# fossil lodge that reminds me, can computers monitor traffic from other frequencies? and how

you should probably be more clear/specific about what you mean, but I'll take a guess and I think this might be relevant

with the right hardware they can, it all depend on what hardware you have and what frequencies you want to listen to, if it's not normal wifi or bluetooth traffic you probably want to take a look at hooking up a SDR (software defined radio) to your computer
some wifi chips can even function like a SDR to a limited degree with the right drivers, but severely constrained to which part of the spectrum it can access, as the chip and antennas are made for the wifi bands

ember ledge
cloud spruce
fossil lodge
cloud spruce
# fossil lodge mostly would like to see things like IoT traffic

still a bit wide as it can mean normal network traffic (over network cables or wifi) or internet/WAN connection through the mobil phone networks (3G/4G/5G/LTE) or more esoteric networks like LoRa
but my best guess is that you are probably after the zigbee, z-wave and x10 frequencies and maybe even bluetooth
most of which will be encrypted today, with x10 being the exception

fossil lodge
#

yeah, nothing specific in mind, just would be nice to know how to mess with IoT devices if I wanted to 😄

sudden torrent
#

how does in pycharm this configurations work when creating new project?

#

am new in python and in pycharm

#

like I jumped from vs2022 to pycharm only bcs of the tutorials

cloud spruce
ember ledge
#

hey guys why does ```python
urllib.request.urlopen(some404website).getcode()

#

how can I get the desired output?

frozen drum
#

use the requests library

#

you need to catch the HTTPError to get the body

ember ledge
#

ok I'll check

ember ledge
worldly lotus
#

I am having some trouble with hosting a socket server. I am using a socket stream on port 9999. However the server can only be accessed locally. Any idea how to solve this?

steady horizon
#

They mostly communicate configurations and settings and stuff like that.

cloud spruce
wise jungle
ember ledge
#

I was wondering if there is a way that I can create and host a server and host
a python program to simply text my friend?
on internet not on LAN btw

cloud spruce
# ember ledge I was wondering if there is a way that I can create and host a server and host ...

yes, it's doable, and what @wise jungle just wrote applies directly to you as well then

you probably want some free DDNS service too, so that they can reach the service that you'll be hosting without having to know your IP address
your IP address will probably changing from time to time, so you need to have something running in the background to periodically check if the IP address has changed and if the DDNS record needs updating

also, if you don't want anyone else to be able to listen in to that traffic with relative ease you probably want a ssl/tls certificate as well, https://letsencrypt.org/ is good for that but they have a pretty short lifetime, so you'll need something that auto-renews the certificate periodically as well before they expire

wise jungle
#

there are some tutorials on youtube that you can follow along

#

make sure you have a static ip

#

and not a shared ip like most isps do these days

ember ledge
wise jungle
#

lol

#

i use them on a regular bases for everything

#

outside of LAN

#

make sure your isp doesnt provide you with a CGNat IP address so that your able to port forward

ember ledge
#

can I add you friend to ask on this matter sometimes?

wise jungle
#

no just ping me here

ember ledge
cloud spruce
sturdy hollow
#

Hey, has anyone a good video recommendation to implement a programm in a client script to check for an update of the server and THEN to update the client script/exe itself...? - Thx in advance :)

#

Hope the question is somewhat understandable

wise jungle
sturdy hollow
#

Yeah... That's what I was thinking... But how can a Script/Programm/Exe Update itself is much more interesting 👍

wise jungle
#

i dont suggest copying it into the same file until u get the code down

sturdy hollow
#

Oh... Okey I think I get the idea... Tbh I thought of that specific option but assumed it would be much more complex in nature

sturdy hollow
wise jungle
#

np

lavish thicket
#

hey, i have to make a program for my school that needs to run at 1 computer/server and needs to access all the computers in a range of some ip's and give me some info, i have the part where he gets the info of the local machine and also the part where he loops all the ip's that are given but i don't know how to acces the other computers, i use python for everything

narrow quarry
#

can we do python as a Websocket Server

but for the Server-Side Web Server, I will use Node.js, PHP, Java, Go, or other non-python?

Yes, Node.js has popular Socket.IO module, but thats not what I am trying to do, I just want to understand the WebSocket

frigid haven
#

Hi Guys

#

is there anyone knows about networking

#

cisco

#

?

wise jungle
#

Is there something out there thats a non connectionless UDP framework

unreal wren
#

requests.post(localhost, files={‘file’: open(fpath, “rb”)})

#

Not sending the binary file

#

Flask says the request is filename and none type for data of file

#

I’m trying to send a binary based file (binary data numpy arrays file .npy) 20MB+ to a flask server ( currently localhost) and save the exact file (.npy)

wise jungle
#

so you have a numpy array?

#

@unreal wren

#

you should use msgpack if its a numpy array your trying to send

livid crater
#

(I'm reposting my question here from a help channel)

Hello, I have a scapy question.

When I create a packet using fuzz, the fields get set to a random value. However, the fields only take on a certain value when building it to a bytes representation. Can I "fix" these fields before converting it to a bytes representation?

Below some code in interactive scapy to show what I mean:

>>> p = fuzz(IP())
>>> p.show()
###[ IP ]###
  version   = <RandNum>
  ihl       = None
  tos       = <RandByte>
  len       = None
  id        = <RandShort>
  flags     = 4
  frag      = <RandNum>
  ttl       = <RandByte>
  proto     = <RandByte>
  chksum    = None
  src       = 127.0.0.1
  dst       = 127.0.0.1
  \options   \

>>> p_fixed = IP(bytes(p))
>>> p_fixed.show()
###[ IP ]###
  version   = 2
  ihl       = 5
  tos       = 0x59
  len       = 20
  id        = 19047
  flags     = MF+evil
  frag      = 7482
  ttl       = 127
  proto     = smp
  chksum    = 0x5574
  src       = 127.0.0.1
  dst       = 127.0.0.1
  \options   \

I'd like a better way to convert from p to p_fixed. The problem with doing it this way, is that the information about the packet type is lost. I'd like to retain that information and just "fix" the fields in the internal representation. I've looked through the source of scapy but can't seem to find a way to do this easily. I also can't seem to find the right keywords to google. If someone knows how, it would help greatly!

Thank you in advance.

fossil lodge
#

read about someone using a self signed certificate for this but ehh

prisma cobalt
#

what, TCP connection and then UDP???

fossil lodge
#

yes it contacts main service through TCP first and then establishes UDP connection between client

prisma cobalt
#

i should point out that UDP is connectionless here

#

i think your mismatching some terms

prisma cobalt
#

i dont understand

fossil lodge
#

by that I mean it starts using UDP

prisma cobalt
#

got you

cloud spruce
# fossil lodge found out the traffic is encrypted through a TCP connection before it goes to UD...

that's the howl idea with TLS, everything needed to decrypt isn't exchanged in the handshake, otherwise it would not be secure and debugging encrypted traffic can be a real pain even if you have all the keys that is needed for decryption
generally speaking the TLS handshake uses asymmetric cryptography to securely exchange/agree upon symmetric keys for use with symmetric ciphers that is used for the bulk encryption of the data that one wants to transfer securely
you can decrypt traffic that doesn't use forward secrecy (FS/PFS) if you get hold of the private key that is associated with the certificate used, unless the connection also use a client certificate (mTLS), then you need to get hold of that private key as well
for traffic that is encrypted with algorithms that provides forward secrecy those private keys will get you nowhere, then you instead have to get hold of the session keys or session secrets from either the server or the client applications: https://support.f5.com/csp/article/K50557518

i recently replied to another question about signing that you could read for a short introduction to some of the underlying cryptography used in the TLS handshake
this is a link to that question and my replies that might interest you is the two replies that follows just after the question: #cybersecurity message

prisma cobalt
#

^^

cloud spruce
#

sorry for my long form answers 😆

fossil lodge
#

np, nice to have well put answers, will likely learn more 😄

prisma cobalt
cloud spruce
# fossil lodge read about someone using a self signed certificate for this but ehh

when we are on the subject of self signed certificates, they don't provide weaker cryptography, only non-existent trust in that it comes from whom they say it come from and can thous be swapped out by someone else that can intercept and terminate the TLS connection like a transparent proxy and generates certificates on the fly to act as a server towards the client and as a client towards the server
but if the two parties has already exchanged the self signed certificate out of band using a trusted secure channel and the client has installed the certificate as a trusted certificate for that server address they will still be able to trust the self signed certificate even if it's not best practice to do it this way (one would typically use a private/custom root CA for that)

prisma cobalt
#

to slightly continue this. web browsers come with trusted certificates pre-installed which is why most HTTPS websites can be seen as secured. most browsers also allow you to import your own certificates for use. for instance:

fossil lodge
#

the server actually allows a connection without tsl but the client uses tsl, I guess I could try to stop the tsl packets and swap them for normal ones but that would require lower level stuff ig

fossil lodge
prisma cobalt
fossil lodge
#

ig yeah

prisma cobalt
#

since your swapping out the packets, the client wont receive their expected trusted message

#

whats your end goal?

fossil lodge
#

decrypt the packets between client and server to sniff the packets

prisma cobalt
#

i assume we are talking HTTP here?

cloud spruce
fossil lodge
#

yes, I'm assuming the https traffic will have a key to decrypt the UDP traffic that comes after

cloud spruce
#

i'm guessing the udp traffic is a vpn tunnel of some kind?

fossil lodge
#

basically there's a system application that has a HTTPS connection to their servers and a client that uses the system application to authenticate and establish a connection UDP connection to the client

cloud spruce
#

sounds very much like a vpn tunnel setup to me

fossil lodge
#

actually the UDP traffic might go through the system application as well

fossil lodge
#

if I were to make a self signed certificate, how exactly would I decrypt the traffic? I know tools like fiddler have this implemented but I doubt it will magically make the packets readable

Also can I make scapy parse the packets I receive from a socket? or does it only know how to parse with sniff() and pcaps

sweet dragon
#

do torrenters mainly download copyrighted content?

cloud spruce
# sweet dragon do torrenters mainly download copyrighted content?

depends on who you ask, the average windows or mac person would probably tell you yes, some linux people will probably tell you no, since quite a bit of larger open source software such as distribution install images are available as torrents as well as normal downloads

fading trellis
#
server {
    listen 80;
    root /var/www/website.com;
    index index.html;
    server_name website.com;

    location / {
        # Help Here
        if ($request_uri ~ ^/(.*)\.html) {
            return 302 /$1;
        }
        try_files $uri $uri.html $uri/ =404;
    }
}```
When I use this config, visiting website.com automatically redirects to website.com/index
Any idea how to fix?
cloud spruce
fading trellis
cloud spruce
cloud spruce
# fading trellis So users do not have to visit domain.com/page.html, they should be able to go to...

just using your try_files line will already make it so that it first tries to find a file under /var/www/website.com that matches exactly the url path sent from the browser
if that fails it will then try to find a file with the same path again but with a .htmlextension (which is what you say that you are looking for)
if that also fails it will try see if there is a directory with the same path as before (by appending the path with a /
finally if everything before this has failed it will return a 404 "page not found" error response

cloud spruce
cloud spruce
# fading trellis ```nginx server { listen 80; root /var/www/website.com; index index....

what your if statement is doing is redirecting any typed url with a .html extension to the same url but without the .html extension

if all you want to do is show the content of the file /var/www/website.com/about.html if someone visits http://website.com/about the try_files line already does that without the if statement
without the if statement one would also be able to visit http://website.com/about.html and see the same page without being redirected, all the if statement would do here is to stop this from working and instead redirect such a request to http://website.com/about and then show the page, which is an extra request/step

rigid copper
#

Has anyone encountered a situation where random CSS/JS files fail to be loaded from a Flask server? It seems to only happen on Chromium browsers. So far, I have found basically no documentation regarding this error, so I have no idea exactly what is causing this. FYI, this all started happening from 30/3 onwards, and reverting my code to earlier commits did not fix the issue.

wise jungle
#

currently its not encrypted but you can easily do it

solar trench
#

can someone help me out, I got a networking problem in #help-pie

#

thanks

prisma cobalt
digital brook
wise jungle
wise jungle
#

for some reason when a third person connects the shit starts lagging

wise jungle
#

i think i cameup with a solution of just threading the data sent instead of looping through

wise jungle
#

i lied

#

i have no clue why the latency is doublin everytime someone joins

wary breach
#

how would i get ips of all of the devices on my network

rigid copper
twin thicket
#

Hey all

#

is this channel friendly towards Questions? etc

#

Attempting to write a an ssl client using socket -- but whilst i am attempting to connect using socat i get this

cloud spruce
#

!code

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.

cloud spruce
#

@twin thicket please use one of the above methods to post your code to the channel again instead of a screen shot

unreal wren
#

Does ssh work across separate networks

cloud spruce
cloud spruce
# wise jungle i have no clue why the latency is doublin everytime someone joins

try rewriting both your client and server to use non blocking io sockets and select() for picking up which sockets has data ready for reading or has a new error state to be handled

It might also be good to change the read buffer size to at least 1472 bytes or something like that to be sure you can read the content of a howl packet off the wire at a time

wise jungle
prisma cobalt
# wise jungle How do use non blocking io sockets?

instead of using threads, you can check the state of each socket in a loop to see which ones have data ready to be read. this stops a recv call from blocking the main thread and removes the overhead of switching threads which the current method uses

wise jungle
cloud spruce
#

and you will only be reading from the sockets that has something on them, select takes care of finding out which those are

cloud spruce
#

non blocking io is a very important subject that is good to get familiarized with

#

even if you use threads you might get problems with blocking io if you are handling more then just one reading from one socket in that thread

#

as the blocking will make just make the howl thread wait for data to arrive from that socket before it can do anything else

#

that means that you would need a separate thread for reading the audio data from your local microphone and transmit that data if you're not using blocking in your voice chat client

wise jungle
#

The only thing i can think of doing is creating multiple sub servers that handle data from each client

#

But that would take up the ports but at this point i dont think is a problem

#

Ill go home and try and wrote a solution

cloud spruce
#

i would definitely suggest either a non-blocking io based server using sock.setblocking(False) and select
otherwise you can spawn a new thread for each data stream you want to read from (in the client that would be one thread for the socket connected to the server and another thread for reading from the microphone and send the that data in that same thread to the same socket that you are reading from in the other thread)

wise jungle
#

In tcp i can do cliet, addr = sock.accept()

#

Then thread the connection so that each client is handled

unreal wren
wise jungle
prisma cobalt
#

youve used the select module?

wise jungle
wise jungle
#

But i rather not want to take up a lot of ports

cloud spruce
cloud spruce
wise jungle
#

Ill write m solution and show you ut

#

Give me likr 20 min

#

actually

#

the more i think about it

#

the more i feel like it might be a client side issue

#

ima try sumthing

cloud spruce
# wise jungle Ill write m solution and show you ut

what you do is mark add the server socket that you have issued bind() and listen() on to the list of sockets that you check with select to see if there is anything to read from them
select will (amongst other things) return a list of all sockets that has something to read from
then loop through that list and you use an if statement to check if it's the same as the server listening socket, in that case you have logic to accept() the connection and add it to the list of client connections that you will also run select() on later on, and if it isn't that socket it's one of the clients sockets that you need to handle as such

wise jungle
#

im not using tcp !?

#

im using UDP

#

i easily handle tcp connections i have no problem with tcp

#

im struggling with UDP

prisma cobalt
#

you can use select module with UDP as well

#

since they block when calling recvfrom

cloud spruce
wise jungle
#

you cant listen() or accept() in UDP

#

cause if you can then i wouldnt have had this issue

wise jungle
cloud spruce
#

right, that's true 😆

prisma cobalt
#

assuming your sending data to multiple clients as well as recving
you would want the select module to check the UDP server socket with a timeout so if theres no data you can focus on sending other data to other clients rather then blocking with the recvfrom call

cloud spruce
#

you just have to bind() (without listen()) and recvfrom() instead

wise jungle
#

what the hell

#

have you guys read my code

#

at all

#

ive made these changes

    def handleConnection(self):
        while True:
            try:
                d, a = self.udp_server.recvfrom(4096)
                self.mainServer.clients[a] = time.time()
                if a != self.addr:
                    self.udp_server.close()
                    break
                serverHandler(self.mainServer, d, a)
            except Exception as e:
                print(e)
                
    def timeoutHandler(self):
        timeout = 1
        while True:
            connectionHandler(self, timeout)
            
    def acceptConnection(self):
        timeout = 1
        while True:
            try:
                d, a = self.udp_server.recvfrom(4096)
                self.clients[a] = time.time()
                if a not in self.connections:
                    if d == b"connection":
                        self.udp_server.sendto(d,a)
                        self.connections.append(a)
                        self.port += 1
                        Server(self.port, True, self, a)
                        print("Get connecting from ", a)
                else:
                    print(f"{a} trying to connect!?")
                    #for c in self.connections:
                    #    if a != c:
                    #        self.udp_server.sendto(d, c)
                #self.udp_server.timeout(0.050)
            except Exception as ex:
                pass
#
    #server class
    def __init__(self, port, isSubServer=False, mainServer=None, a=None):
        threading.Thread.__init__(self)
        self.port = port
        self.mainServer = mainServer
        self.addr = a
        
        server_config = (self.host, self.port)
        self.udp_server.bind(server_config)
        self.udp_server.setblocking(0)
        self.clients = dict()

        if not isSubServer:
            self.acceptConnectionT = threading.Thread(target=self.acceptConnection, daemon=True)
            self.acceptConnectionT.start()
            self.timeoutHandlerT = threading.Thread(target=self.timeoutHandler, daemon=True)
            self.timeoutHandlerT.start()
        else:
            self.handleConnectionT = threading.Thread(target=self.handleConnection,daemon=True)
            self.handleConnectionT.start()
#

i think this would work

#

what do you guys think @cloud spruce @prisma cobalt

prisma cobalt
#

why would you close your server if the connection isnt self.addr?

wise jungle
#

maybe thats OD

#

ima just do pass or something

#

or ill just do if a == self.addr

prisma cobalt
#

wait does this use multiple ports?

wise jungle
#

yes

prisma cobalt
#

how is the client supposed to know which port to connect to?

wise jungle
#

thsi was the solution i was thinking of

wise jungle
#

to the main hub

#

so you see in the acceptconnection

#
                 if a not in self.connections:
                    if d == b"connection":
                        self.udp_server.sendto(d,a)
                        self.connections.append(a)
                        self.port += 1
                        Server(self.port, True, self, a)
                        print("Get connecting from ", a)
#

in self.udp_server.sendto(d,a) ill change d for a port

prisma cobalt
#

this isnt a production ready server
what if you run out of ports
in reality this is done differently

wise jungle
#

and have it be the same ip

wise jungle
#

but i think overall it wont be that bad

prisma cobalt
#

not to mentions all those threads you create

#

sure, if it works 😂

wise jungle
#

i mean someone could probably open like 10000 ports

prisma cobalt
#

if it works to your requirements then it works perfectly™️

#

lmao

wise jungle
#

and then have 9999 people connect to a main server

#

per ip

#

so technically you can have multiple machines hosting upto 10000 ports

#

but ive done 25 port range

#

ima test it

#

i doubt it will work

#

yup dis shit did not work x)

#

nvm wait

#

i forgot to encode

cloud spruce
#

why do every client need it's own port?
is it so that a client can change source ip and/or source port and you'll still know it's the same client?
but then anyone can impersonate that client by just sending traffic to that clients port on the server

wise jungle
#

that way you cant just send packets

#

and gonna have to connect through the main server

#
[WinError 10035] A non-blocking socket operation could not be completed immediately
[WinError 10035] A non-blocking socket operation could not be completed immediately
#

: ?

#

we do a little bit of trolling

#

why am i getting this error now

#

i wasnt getting this earlier

wise jungle
#

my laptop blue screened LOL

wise jungle
cloud spruce
wise jungle
#

im hella stuck

#

im actually clueless on what to do

#

i know there is a way to do it all on 1 port but i really dont know how

cloud spruce
wise jungle
#

im so lost

#

i cant find anything for UDP

cloud spruce
#

i'll see if i can try something out over here

wise jungle
wise jungle
#

if u get somewhere ping me @cloud spruce ty

cloud spruce
# wise jungle appreciate you

i'm looking through your code at https://github.com/e1pupper/VoiceChat/blob/main/server.py

one way to get a non-blocking udp socket (and this doesn't even require a separate call) is: udp_server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM | socket.SOCK_NONBLOCK)

you can change the code and make a lot simpler when using udp, like not using threads right now (at least until you have lots of clients to send the same piece of data to)
especially: don't create a new thread for every non-blocking .recvfrom()

wise jungle