diff --git a/client-server-1.pcapng b/client-server-1.pcapng new file mode 100644 index 0000000..71ca456 Binary files /dev/null and b/client-server-1.pcapng differ diff --git a/client-server-2.pcapng b/client-server-2.pcapng new file mode 100644 index 0000000..d0a22b7 Binary files /dev/null and b/client-server-2.pcapng differ diff --git a/gitea_api.py b/gitea_api.py new file mode 100644 index 0000000..6ae2b8d --- /dev/null +++ b/gitea_api.py @@ -0,0 +1,21 @@ +import os +import requests + +TOKEN = os.getenv("GITEA_TOKEN") + +if not TOKEN: + print("Токен не найден") + raise SystemExit(1) + +headers = { + "Authorization": f"token {TOKEN}" +} + +response = requests.get( + "https://git.vyatsu.ru/api/v1/user", + headers=headers, + timeout=10 +) + +print(response.status_code) +print(response.text) \ No newline at end of file diff --git a/gitea_create_issue.py b/gitea_create_issue.py new file mode 100644 index 0000000..b0b72f3 --- /dev/null +++ b/gitea_create_issue.py @@ -0,0 +1,18 @@ +import os +import requests + +token = os.getenv("GITEA_TOKEN") +if not token: + print("Токен не найден") + exit() + +url = "https://git.vyatsu.ru/api/v1/repos/stud203985/2task/issues" + +response = requests.post( + url, + headers={"Authorization": f"token {token}"}, + json={"title": "Тестовое issue", "body": "Создано через API"} +) + +print(response.status_code) +print(response.text) \ No newline at end of file diff --git a/http-requests.pcapng b/http-requests.pcapng new file mode 100644 index 0000000..ef98e28 Binary files /dev/null and b/http-requests.pcapng differ diff --git a/http.pcapng b/http.pcapng new file mode 100644 index 0000000..1ff66c2 Binary files /dev/null and b/http.pcapng differ diff --git a/http_requests_client.py b/http_requests_client.py new file mode 100644 index 0000000..5247a06 --- /dev/null +++ b/http_requests_client.py @@ -0,0 +1,7 @@ +import requests + +response = requests.get("http://vyatsu.ru", timeout=10) + +print("Статус:", response.status_code) +print("Первые 500 символов:") +print(response.text[:500]) \ No newline at end of file diff --git a/http_socket_client.py b/http_socket_client.py new file mode 100644 index 0000000..e765030 --- /dev/null +++ b/http_socket_client.py @@ -0,0 +1,25 @@ +import socket + +client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +client.connect(("vyatsu.ru", 80)) + +request = ( + "GET / HTTP/1.1\r\n" + "Host: vyatsu.ru\r\n" + "User-Agent: python-socket-client/1.0\r\n" + "Accept: */*\r\n" + "Connection: close\r\n" + "\r\n" +) + +client.sendall(request.encode()) + +response = b"" +while True: + part = client.recv(4096) + if not part: + break + response += part + +print(response.decode(errors="replace")) +client.close() \ No newline at end of file diff --git a/http_socket_client_requeststype.py b/http_socket_client_requeststype.py new file mode 100644 index 0000000..50171c4 --- /dev/null +++ b/http_socket_client_requeststype.py @@ -0,0 +1,26 @@ +import socket + +client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +client.connect(("vyatsu.ru", 80)) + +request = ( + "GET / HTTP/1.1\r\n" + "Host: vyatsu.ru\r\n" + "User-Agent: python-requests/2.31.0\r\n" + "Accept-Encoding: gzip, deflate\r\n" + "Accept: */*\r\n" + "Connection: close\r\n" + "\r\n" +) + +client.sendall(request.encode()) + +response = b"" +while True: + part = client.recv(4096) + if not part: + break + response += part + +print(response.decode(errors="replace")) +client.close() \ No newline at end of file diff --git a/tcp_client.py b/tcp_client.py new file mode 100644 index 0000000..5e04ce5 --- /dev/null +++ b/tcp_client.py @@ -0,0 +1,12 @@ +import socket + +client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +client.connect(("127.0.0.1", 10000)) + +message = input("Введите сообщение: ") +client.sendall(message.encode()) + +data = client.recv(1024) +print(f"Ответ от сервера: {data.decode()}") + +client.close() \ No newline at end of file diff --git a/tcp_server.py b/tcp_server.py new file mode 100644 index 0000000..f42f4ac --- /dev/null +++ b/tcp_server.py @@ -0,0 +1,25 @@ +import socket + +server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +server.bind(("0.0.0.0", 10000)) +server.listen(1) + +print("TCP сервер запущен") + +while True: + conn, addr = server.accept() + print(f"Подключение от {addr}") + + data = conn.recv(1024) + if not data: + conn.close() + continue + + conn.sendall(data.upper()) + conn.close() + + if data.upper() == b"EXIT": + break + +server.close() +print("TCP сервер остановлен") \ No newline at end of file diff --git a/udp_client.py b/udp_client.py new file mode 100644 index 0000000..e641313 --- /dev/null +++ b/udp_client.py @@ -0,0 +1,11 @@ +import socket + +client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + +message = input("Введите сообщение: ") +client.sendto(message.encode(), ("127.0.0.1", 10011)) + +data, _ = client.recvfrom(1024) +print(f"Ответ от сервера: {data.decode()}") + +client.close() \ No newline at end of file diff --git a/udp_server.py b/udp_server.py new file mode 100644 index 0000000..c60f0dd --- /dev/null +++ b/udp_server.py @@ -0,0 +1,14 @@ +import socket + +server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +server.bind(("0.0.0.0", 10011)) + +print("UDP сервер запущен") + +while True: + data, addr = server.recvfrom(1024) + message = data.decode() + print(f"Сообщение от {addr}: {message}") + + response = f"[UDP] {message[::-1]}" + server.sendto(response.encode(), addr) \ No newline at end of file