Ignore:
Timestamp:
Aug 26, 2011, 8:54:24 PM (14 years ago)
Author:
rick
Message:

Map a SSID to an organization to play nice with differnt SSIDs.

Location:
src/django_gheat/gheat
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/gheat/admin.py

    r9395 r9579  
    22from django.contrib import admin
    33
    4 admin.site.register(Accespoint)
     4class AccespointAdmin(admin.ModelAdmin):
     5  list_display = ['ssid','mac', 'organization']
     6  search_fields = ['ssid', 'mac', 'organization']
     7
     8admin.site.register(Accespoint, AccespointAdmin)
    59admin.site.register(Apparatuur)
    610admin.site.register(Gebruiker)
  • src/django_gheat/gheat/management/commands/import_droidstumbler.py

    r9565 r9579  
    9696      ssid, encryption = ap_pool[bssid]
    9797      # Special trick in SSID ts avoid escaping in later stage
    98       item = str((bssid.upper(),ssid.replace('%','%%'),encryption))
     98      item = str((bssid.upper(),ssid.replace('%','%%'),encryption,Accespoint.get_organization(ssid)))
    9999      sql_values.append(item)
    100     counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`)',sql_values)
     100    counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`, `organization`)',sql_values)
    101101
    102102  # Build mapping for meting import
  • src/django_gheat/gheat/management/commands/import_kismet.py

    r9565 r9579  
    7676      ssid, encryption = ap_pool[bssid]
    7777      # Special trick in SSID ts avoid escaping in later stage
    78       item = str((bssid.upper(),ssid.replace('%','%%'),encryption))
     78      item = str((bssid.upper(),ssid.replace('%','%%'),encryption,Accespoint.get_organization(ssid)))
    7979      sql_values.append(item)
    80     counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`)',sql_values)
     80    counters['ap_added'] = bulk_sql('gheat_accespoint (`mac`, `ssid`, `encryptie`, `organization`)',sql_values)
    8181
    8282  # Determine which Wireless Clients to add
  • src/django_gheat/gheat/models.py

    r9562 r9579  
    5757    return self.mac
    5858
     59
     60ORGANIZATION_CHOICES = (
     61  ('WirelessLeiden', 'Wireless Leiden'),
     62)
     63
    5964class Accespoint(models.Model):
    6065  mac = models.CharField(max_length=17)
    6166  ssid = models.CharField(max_length=64)
     67  organization = models.CharField(max_length="50",choices=ORGANIZATION_CHOICES,null=True,blank=True)
    6268  encryptie = models.BooleanField()
    6369  class Meta:
     
    6571  def __unicode__(self):
    6672    return "%s - %s" % (self.mac, self.ssid)
     73
     74  @staticmethod
     75  def get_organization(ssid):
     76    """ Try to determine the organization via the SSID """
     77    organization = ''
     78    if ssid.startswith('ap') and ssid.endswith('wleiden.net'):
     79      organization = 'WirelessLeiden'
     80    elif ssid.startswith('ap') and 'WirelessLeiden' in ssid:
     81      organization = 'WirelessLeiden'
     82    return organization
     83
     84  def save(self, *args, **kwargs):
     85    self.organization = self.get_organization(self.ssid)
     86    super(Accespoint, self).save(*args, **kwargs)
    6787
    6888class Gebruiker(models.Model):
Note: See TracChangeset for help on using the changeset viewer.