<commit_before>#!/usr/bin/python
 
# Python program that can send out M-SEARCH messages using SSDP (in server
# mode), or listen for SSDP messages (in client mode).
 
import sys
from twisted.internet import reactor, task
from twisted.internet.protocol import DatagramProtocol
# from netInterfaceStatus import getNetworkInt
from netInterfaceStatus import getServerIP
import re
import os

ssdpAddr = '192.168.3.11'
ssdpPort = 1900

httpPort = 80

serverIP = getServerIP()

MSOK = 'HTTP/1.1 200 OK\r\nCACHE-CONTROL:max-age=1800\r\nDATE:Mon 03 Jan 2000 11:29:31 GMT\r\nEXT:\r\nLOCATION:http://%s:%d/desc.xml\r\nSERVER:CW/1.0 UPnP/1.1 CWUpnp/1.1\r\nST:urn:ses-com:device:SatIPServer:1\r\nUSN:uuip:7f764937-d0d7-11e1-9b23-00059e9651fd::urn:ses-com:device:SatIPServer:1\r\nBOOTID.UPNP.ORG:998\r\nCONFIGID.UPNP.ORG:2212703\r\nDEVICEID.SES.COM:0\r\n\r\n' % (serverIP, httpPort)


# SSDP_ADDR = '192.168.3.11'
# # SSDP_ADDR = '192.168.1.38'
# # SSDP_ADDR2 = '192.168.1.101'
# SSDP_PORT = 1900
# HTTP_PORT = 80
# SERVER_IP = getServerIP()
 
# MS = 'M-SEARCH * HTTP/1.1\r\nHOST: %s:%d\r\nMAN: "ssdp:discover"\r\nMX: 2\r\nST: ssdp:all\r\n\r\n' % (SSDP_ADDR, SSDP_PORT)
# NO =[]
# a = 'NOTIFY * HTTP/1.1\r\nHOST: %s:%d\r\nBOOTID.UPNP.ORG:981\r\nCONFIGID.UPNP.ORG:12555367\r\nCACHE-CONTROL: max-age=1800\r\nLOCATION:http://192.168.1.61/desc.xml\r\nNT:upnp:rootdevice\r\nNTS:ssdp:alive\r\nSERVER:CW/1.0 UPnP/1.1 CWUpnp/1.1\r\nUSN:uuip:7f764937-d0d7-11e1-9b23-00059e9651fd::upnp:rootdevice\r\nDEVICEID.SES.COM:0\r\n\r\n' % (SSDP_ADDR, SSDP_PORT)
# b = 'NOTIFY * HTTP/1.1\r\nHOST: %s:%d\r\nBOOTID.UPNP.ORG:981\r\nCONFIGID.UPNP.ORG:12555367\r\nCACHE-CONTROL: max-age=1800\r\nLOCATION:http://19172.16.31.10/desc.xml\r\nNT:uuid:7f764937-d0d7-11e1-9b23-00059e9651fd\r\nNTS:ssdp:alive\r\nSERVER:CW/1.0 UPnP/1.1 CWUpnp/1.1\r\nUSN:uuip:7f764937-d0d7-11e1-9b23-00059e9651fd\r\nDEVICEID.SES.COM:0\r\n\r\n' % (SSDP_ADDR, SSDP_PORT)
# c = 'NOTIFY * HTTP/1.1\r\nHOST: %s:%d\r\nBOOTID.UPNP.ORG:981\r\nCONFIGID.UPNP.ORG:12555367\r\nCACHE-CONTROL: max-age=1800\r\nLOCATION:http://192.168.1.61/desc.xml\r\nNT:urn:ses-com:device:SatIPServer:1\r\nNTS:ssdp:alive\r\nSERVER:CW/1.0 UPnP/1.1 CWUpnp/1.1\r\nUSN:uuip:7f764937-d0d7-11e1-9b23-00059e9651fd::urn:ses-com:device:SatIPServer:1\r\nDEVICEID.SES.COM:0\r\n\r\n' % (SSDP_ADDR, SSDP_PORT)
# MSOK = 'HTTP/1.1 200 OK\r\nCACHE-CONTROL:max-age=1800\r\nDATE:Mon 03 Jan 2000 11:29:31 GMT\r\nEXT:\r\nLOCATION:http://%s:%d/desc.xml\r\nSERVER:CW/1.0 UPnP/1.1 CWUpnp/1.1\r\nST:urn:ses-com:device:SatIPServer:1\r\nUSN:uuip:7f764937-d0d7-11e1-9b23-00059e9651fd::urn:ses-com:device:SatIPServer:1\r\nBOOTID.UPNP.ORG:998\r\nCONFIGID.UPNP.ORG:2212703\r\nDEVICEID.SES.COM:0\r\n\r\n' % (SERVER_IP, HTTP_PORT)
# NO.append(a)
# NO.append(b)
# NO.append(c)
# counter = 0

class Base(DatagramProtocol):
	def datagramReceived(self, datagram, address):
		datagram_array = datagram.rsplit('\r\n')
		print "datagram_array", datagram_array
		# first_line = datagram.rsplit('\r\n')[0]

		try: 
			first_line = datagram_array[0]
			second_line = datagram_array[2]

			match = re.search(r'M-SEARCH',first_line)
			if match:
				match2 = re.search(r'ssdp:discover',datagram)
				if match2:
					print 'received M-SEARCH from SAT>IP clients'
					print 'sending replay'
					print 'ip', address[0], 'port', address[1]
					self.ssdp.write(MSOK, (address[0], address[1]))<commit_msg>scan for tivizen for multiple users<commit_after>#!/usr/bin/python
 
# Python program that can send out M-SEARCH messages using SSDP (in server
# mode), or listen for SSDP messages (in client mode).
 
import sys
from twisted.internet import reactor, task
from twisted.internet.protocol import DatagramProtocol
# from netInterfaceStatus import getNetworkInt
from netInterfaceStatus import getServerIP
import re
import os

ssdpAddr = '192.168.3.11'
ssdpPort = 1900

httpPort = 80

serverIP = getServerIP()

MSOK = 'HTTP/1.1 200 OK\r\nCACHE-CONTROL:max-age=1800\r\nDATE:Mon 03 Jan 2000 11:29:31 GMT\r\nEXT:\r\nLOCATION:http://%s:%d/desc.xml\r\nSERVER:CW/1.0 UPnP/1.1 CWUpnp/1.1\r\nST:urn:ses-com:device:SatIPServer:1\r\nUSN:uuip:7f764937-d0d7-11e1-9b23-00059e9651fd::urn:ses-com:device:SatIPServer:1\r\nBOOTID.UPNP.ORG:998\r\nCONFIGID.UPNP.ORG:2212703\r\nDEVICEID.SES.COM:0\r\n\r\n' % (serverIP, httpPort)


# SSDP_ADDR = '192.168.3.11'
# # SSDP_ADDR = '192.168.1.38'
# # SSDP_ADDR2 = '192.168.1.101'
# SSDP_PORT = 1900
# HTTP_PORT = 80
# SERVER_IP = getServerIP()
 
# MS = 'M-SEARCH * HTTP/1.1\r\nHOST: %s:%d\r\nMAN: "ssdp:discover"\r\nMX: 2\r\nST: ssdp:all\r\n\r\n' % (SSDP_ADDR, SSDP_PORT)
# NO =[]
# a = 'NOTIFY * HTTP/1.1\r\nHOST: %s:%d\r\nBOOTID.UPNP.ORG:981\r\nCONFIGID.UPNP.ORG:12555367\r\nCACHE-CONTROL: max-age=1800\r\nLOCATION:http://192.168.1.61/desc.xml\r\nNT:upnp:rootdevice\r\nNTS:ssdp:alive\r\nSERVER:CW/1.0 UPnP/1.1 CWUpnp/1.1\r\nUSN:uuip:7f764937-d0d7-11e1-9b23-00059e9651fd::upnp:rootdevice\r\nDEVICEID.SES.COM:0\r\n\r\n' % (SSDP_ADDR, SSDP_PORT)
# b = 'NOTIFY * HTTP/1.1\r\nHOST: %s:%d\r\nBOOTID.UPNP.ORG:981\r\nCONFIGID.UPNP.ORG:12555367\r\nCACHE-CONTROL: max-age=1800\r\nLOCATION:http://192.168.1.61/desc.xml\r\nNT:uuid:7f764937-d0d7-11e1-9b23-00059e9651fd\r\nNTS:ssdp:alive\r\nSERVER:CW/1.0 UPnP/1.1 CWUpnp/1.1\r\nUSN:uuip:7f764937-d0d7-11e1-9b23-00059e9651fd\r\nDEVICEID.SES.COM:0\r\n\r\n' % (SSDP_ADDR, SSDP_PORT)
# c = 'NOTIFY * HTTP/1.1\r\nHOST: %s:%d\r\nBOOTID.UPNP.ORG:981\r\nCONFIGID.UPNP.ORG:12555367\r\nCACHE-CONTROL: max-age=1800\r\nLOCATION:http://192.168.1.61/desc.xml\r\nNT:urn:ses-com:device:SatIPServer:1\r\nNTS:ssdp:alive\r\nSERVER:CW/1.0 UPnP/1.1 CWUpnp/1.1\r\nUSN:uuip:7f764937-d0d7-11e1-9b23-00059e9651fd::urn:ses-com:device:SatIPServer:1\r\nDEVICEID.SES.COM:0\r\n\r\n' % (SSDP_ADDR, SSDP_PORT)
# MSOK = 'HTTP/1.1 200 OK\r\nCACHE-CONTROL:max-age=1800\r\nDATE:Mon 03 Jan 2000 11:29:31 GMT\r\nEXT:\r\nLOCATION:http://%s:%d/desc.xml\r\nSERVER:CW/1.0 UPnP/1.1 CWUpnp/1.1\r\nST:urn:ses-com:device:SatIPServer:1\r\nUSN:uuip:7f764937-d0d7-11e1-9b23-00059e9651fd::urn:ses-com:device:SatIPServer:1\r\nBOOTID.UPNP.ORG:998\r\nCONFIGID.UPNP.ORG:2212703\r\nDEVICEID.SES.COM:0\r\n\r\n' % (SERVER_IP, HTTP_PORT)
# NO.append(a)
# NO.append(b)
# NO.append(c)
# counter = 0

class Base(DatagramProtocol):
	def datagramReceived(self, datagram, address):
		datagram_array = datagram.rsplit('\r\n')
		# print "datagram_array", datagram_array
		# first_line = datagram.rsplit('\r\n')[0]

		try: 
			first_line = datagram_array[0]
			second_line = datagram_array[2]

			match = re.search(r'M-SEARCH',first_line)
			if match:
				match2 = re.search(r'ssdp:discover',datagram)
				if match2:
					# print 'received M-SEARCH from SAT>IP clients'
					# print 'sending replay'
					print 'ip', address[0], 'port', address[1]
					self.ssdp.write(MSOK, (address[0], address[1]))
{'fraction_non_alphanumeric': 0.18527843601895735, 'fraction_numerical': 0.11522511848341233, 'mean_word_length': 4.539786710418376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 14, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5581240', 'n_tokens_mistral': 3809, 'n_tokens_neox': 3303, 'n_words': 356}