This commit is contained in:
GandC Snow 2021-10-25 14:51:22 +03:00
parent 05aab5ab41
commit e9a196ff06
4 changed files with 9 additions and 40 deletions

View File

@ -1,24 +0,0 @@
from socket import *
import sys
host = 'localhost'
port = 777
addr = (host,port)
udp_socket = socket(AF_INET, SOCK_DGRAM)
data = input('write to server: ')
if not data :
udp_socket.close()
sys.exit(1)
#encode - перекодирует введенные данные в байты, decode - обратно
data = str.encode(data)
udp_socket.sendto(data, addr)
data = bytes.decode(data)
data = udp_socket.recvfrom(1024)
print(data)
udp_socket.close()

View File

@ -1,5 +0,0 @@
[Global]
IRC_bot_nickname = GandC_LogMon_Bot
IRC_chat_name = #notifications
IRC_host = s1.tomasgl.piv
IRC_port = 6667

View File

@ -1,12 +1,9 @@
## ##
##/dev/udp/ip/port##
##pip3 install irc##
from irc import client, connection
from socket import socket, AF_INET, SOCK_DGRAM
#from os import chdir, path
from threading import Thread
host = '10.10.18.3'
host = '0.0.0.0'
port = 7747
addr = (host,port)
@ -18,9 +15,6 @@ irc_bot_nickname = 'GandC_LogMon_Bot'
s = socket(AF_INET, SOCK_DGRAM) # Socket creation
s.bind(addr) # Bind socket to ip
#chdir(path.dirname(path.abspath(__file__)))
def on_connect(connection, event):
connection.mode(irc_bot_nickname, '+B')
connection.join(irc_chat_name)
@ -41,7 +35,7 @@ Thread(target=reactor.process_forever).start()
while True:
message, addr = s.recvfrom(1024) # receive message
print('client addr: ', addr)
print('info: ', message)
irc.connection.privmsg(irc_chat_name, message)
#print('client addr: ', addr)
#print('info: ', message.decode())
irc.privmsg(irc_chat_name, message.decode().strip())
s.close()

4
start Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
USER_IP=$(echo $SSH_CONNECTION | awk '{print $1}')
MESSAGE="SSH Connection to $HOSTNAME Established $(date "+%Y.%m.%d-%H:%M:%S") from $USER_IP User:$USER"
echo "$MESSAGE" > /dev/udp/10.10.13.8/7747