forked from ungleich-public/cdist
		
	++scan stuff
This commit is contained in:
		
					parent
					
						
							
								09dfcfe81e
							
						
					
				
			
			
				commit
				
					
						bc2948a8a5
					
				
			
		
					 2 changed files with 24 additions and 1 deletions
				
			
		| 
						 | 
					@ -56,6 +56,8 @@ from scapy.all import *
 | 
				
			||||||
# Datetime overwrites scapy.all.datetime - needs to be imported AFTER
 | 
					# Datetime overwrites scapy.all.datetime - needs to be imported AFTER
 | 
				
			||||||
import datetime
 | 
					import datetime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cdist.config
 | 
				
			||||||
 | 
					
 | 
				
			||||||
log = logging.getLogger("scan")
 | 
					log = logging.getLogger("scan")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Trigger(object):
 | 
					class Trigger(object):
 | 
				
			||||||
| 
						 | 
					@ -120,6 +122,19 @@ class Scanner(object):
 | 
				
			||||||
            with open(fname, "w") as fd:
 | 
					            with open(fname, "w") as fd:
 | 
				
			||||||
                fd.write(f"{now}\n")
 | 
					                fd.write(f"{now}\n")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def config(self):
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        Configure a host
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        - Assume we are only called if necessary
 | 
				
			||||||
 | 
					        - However we need to ensure to not run in parallel
 | 
				
			||||||
 | 
					        - Maybe keep dict storing per host processes
 | 
				
			||||||
 | 
					        - Save the result
 | 
				
			||||||
 | 
					        - Save the output -> probably aligned to config mode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def start(self):
 | 
					    def start(self):
 | 
				
			||||||
        self.process = Process(target=self.scan)
 | 
					        self.process = Process(target=self.scan)
 | 
				
			||||||
        self.process.start()
 | 
					        self.process.start()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,4 +54,12 @@ VERBOSE: scan: Host fe80::f29f:c2ff:fe7c:275e is alive
 | 
				
			||||||
VERBOSE: scan: Host fe80::ba69:f4ff:fec5:8db7 is alive
 | 
					VERBOSE: scan: Host fe80::ba69:f4ff:fec5:8db7 is alive
 | 
				
			||||||
VERBOSE: scan: Host fe80::42b0:34ff:fe6f:f863 is alive
 | 
					VERBOSE: scan: Host fe80::42b0:34ff:fe6f:f863 is alive
 | 
				
			||||||
VERBOSE: scan: Host fe80::21b:fcff:feee:f4bc is alive
 | 
					VERBOSE: scan: Host fe80::21b:fcff:feee:f4bc is alive
 | 
				
			||||||
...
 | 
					** Better usage -> saving the env
 | 
				
			||||||
 | 
					    sudo -E cdist scan -b -I wlan0 -vv
 | 
				
			||||||
 | 
					** TODO Implement actual configuration step
 | 
				
			||||||
 | 
					   - Also serves as a nice PoC
 | 
				
			||||||
 | 
					   - Might need to escape literal IPv6 addresses for scp
 | 
				
			||||||
 | 
					** TODO Define how to map link local address to something useful
 | 
				
			||||||
 | 
					   - via reverse DNS?
 | 
				
			||||||
 | 
					   - via link local in manifest?
 | 
				
			||||||
 | 
					** TODO define ignorehosts?
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue