Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
eca991df
Kaydet (Commit)
eca991df
authored
Tem 19, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Change security policy -- only accept requests from current host.
üst
d1bef00f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
21 deletions
+9
-21
pysvr.py
Demo/pysvr/pysvr.py
+9
-21
No files found.
Demo/pysvr/pysvr.py
Dosyayı görüntüle @
eca991df
...
...
@@ -6,13 +6,15 @@ This is really a prototype for the same thing in C.
Usage: pysvr.py [port]
For security reasons, it only accepts requests from the current host.
This can still be insecure, but restricts violations from people who
can log in on your machine. Use with caution!
"""
import
sys
,
os
,
string
,
getopt
,
thread
,
socket
,
traceback
OK_DOMAINS
=
[
".cnri.reston.va.us"
,
".python.org"
]
PORT
=
7585892
%
0xFFFF
# == 49367
PORT
=
4000
# Default port
def
main
():
try
:
...
...
@@ -43,6 +45,7 @@ def main_thread(port):
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
bind
((
""
,
port
))
sock
.
listen
(
5
)
print
"Listening on port"
,
port
,
"..."
while
1
:
(
conn
,
addr
)
=
sock
.
accept
()
thread
.
start_new_thread
(
service_thread
,
(
conn
,
addr
))
...
...
@@ -50,26 +53,11 @@ def main_thread(port):
def
service_thread
(
conn
,
addr
):
(
caddr
,
cport
)
=
addr
try
:
host
,
aliases
,
ipaddrs
=
socket
.
gethostbyaddr
(
caddr
)
except
socket
.
error
:
print
"Don't know hostname for"
,
caddr
return
if
'.'
not
in
host
:
for
a
in
aliases
:
if
'.'
in
a
:
host
=
a
break
else
:
print
"Only a local name (
%
s) for
%
s"
%
(
host
,
caddr
)
return
i
=
string
.
find
(
host
,
'.'
)
domain
=
string
.
lower
(
host
[
i
:])
if
domain
not
in
OK_DOMAINS
:
print
"Connection from"
,
host
,
"not accepted"
if
caddr
!=
socket
.
gethostbyname
(
socket
.
gethostname
()):
print
"Connection from"
,
caddr
,
"not accepted."
return
print
"Thread
%
s has connection from
%
s.
\n
"
%
(
str
(
thread
.
get_ident
()),
host
),
caddr
),
stdin
=
conn
.
makefile
(
"r"
)
stdout
=
conn
.
makefile
(
"w"
,
0
)
run_interpreter
(
stdin
,
stdout
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment