The main Bubble source repository. Contains the Bubble API server, the web UI, documentation and utilities. https://getbubblenow.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

bubble_api.py 914 B

1234567891011121314151617181920212223
  1. from bubble_config import bubble_network, bubble_port
  2. from mitmproxy import ctx
  3. import requests
  4. HEADER_BUBBLE_MATCHERS='X-Bubble-Matchers'
  5. # todo: cache responses by remote_addr+host for a limited time (1 minute?)
  6. def bubble_matchers (remote_addr, flow, host):
  7. headers = {'X-Forwarded-For': remote_addr}
  8. try:
  9. data = {
  10. 'fqdn': host,
  11. 'uri': flow.request.path,
  12. 'userAgent': flow.request.headers['User-Agent'],
  13. 'remoteAddr': flow.client_conn.address[0]
  14. }
  15. response = requests.post('http://127.0.0.1:'+bubble_port+'/api/filter/matchers', headers=headers, data=data)
  16. if response.ok:
  17. return response.json()
  18. ctx.log.warn('bubble_matchers returned '+response.status_code+', returning empty matchers array')
  19. except Exception as e:
  20. ctx.log.warn('bubble_matchers API call failed: '+repr(e))
  21. return []