'Called once when obfsproxy starts.'

@classmethod
def setup(cls, transportConfig):

    util.setStateLocation(transportConfig.getStateLocation())
    cls.weAreClient = transportConfig.weAreClient
    cls.weAreServer = (not cls.weAreClient)
    cls.weAreExternal = transportConfig.weAreExternal
    if (cls.weAreServer and (not cls.weAreExternal)):
        cfg = transportConfig.getServerTransportOptions()
        if (cfg and ('password' in cfg)):
            try:
                cls.uniformDHSecret = base64.b32decode(util.sanitiseBase32(cfg['password']))
            except (TypeError, AttributeError) as error:
                raise base.TransportSetupFailed(('Password    could    not    be    base32    decoded    (%s)' % error))
            cls.uniformDHSecret = cls.uniformDHSecret.strip()
    if cls.weAreServer:
        if (not hasattr(cls, 'uniformDHSecret')):
            srv = state.load()
            cls.uniformDHSecret = srv.fallbackPassword
        if (len(cls.uniformDHSecret) != const.SHARED_SECRET_LENGTH):
            raise base.TransportSetupFailed(('Wrong    password    length    (%d    instead    of    %d)' % len(cls.uniformDHSecret)), const.SHARED_SECRET_LENGTH)
        if (not const.STATE_LOCATION):
            raise base.TransportSetupFailed('No    state    location    set.    If    you    are    using    external    mode,    please    set    it    using    the    --data-dir    switch.')
        state.writeServerPassword(cls.uniformDHSecret)
