Пример #1
0
def icecast_add_listener():
    #logger.info('add_listener {}'.format(request.form))
    if request.form['action'] != 'listener_add':
        return make_response('you just went full retard', 405)
    relay = Relay.get_relay(address=request.form['server'],
                            port=request.form['port'])
    stream = Stream.get_stream(mount=request.form['mount'])
    listener = Listener.create(request.form['ip'], request.form['client'], request.form['agent'], relay.get_stream_relay(stream))
    session.add(listener)
    session.flush()
    relay.update_statistic()
    stream.update_statistic()
    relay.get_stream_relay(stream).update_statistic()
    session.commit()
    return make_response('ok', 200, {'icecast-auth-user': '******'})
Пример #2
0
def icecast_add_listener():
    #logger.info('add_listener {}'.format(request.form))
    if request.form['action'] != 'listener_add':
        return make_response('you just went full retard', 405)
    relay = Relay.get_relay(address=request.form['server'],
                            port=request.form['port'])
    stream = Stream.get_stream(mount=request.form['mount'])
    listener = Listener.create(request.form['ip'], request.form['client'],
                               request.form['agent'],
                               relay.get_stream_relay(stream))
    session.add(listener)
    session.flush()
    relay.update_statistic()
    stream.update_statistic()
    relay.get_stream_relay(stream).update_statistic()
    session.commit()
    return make_response('ok', 200, {'icecast-auth-user': '******'})
Пример #3
0
def finish():
    ret = {'success': False}
    try:
        if not User.check_username(request.form['username']):
            ret['username'] = '******'
        elif len(request.form['password']) == 0:
            ret['password'] = '******'
        elif len(request.form['stream_password']) == 0:
            ret['stream_password'] = '******'
        elif User.get_user(username=request.form['username']) == None:
            ret['success'] = True
            user = User(request.form['username'],
                        User.make_password(request.form['password']),
                        User.make_password(request.form['stream_password']))
            session.add(user)
            session.commit()
        else:
            ret['username'] = '******'
    except KeyError:
        pass
    response = jsonify(ret)
    response.status_code = 200
    return response