Module: Watobo::Interceptor

Included in:
Gui::InterceptEditor, Gui::InterceptorFilterSettingsDialog, Gui::InterceptorUI
Defined in:
lib/watobo/core/interceptor.rb,
lib/watobo/core/intercept_carver.rb,
lib/watobo/core/intercept_filter.rb

Defined Under Namespace

Classes: Carver, CarverRule, Filter, FilterChain, FlagFilter, HttpParmsFilter, MethodFilter, RequestCarver, RequestFilter, ResponseCarver, StatusFilter, UrlFilter

Constant Summary collapse

INTERCEPT_NONE =
0x00
INTERCEPT_REQUEST =
0x01
INTERCEPT_RESPONSE =
0x02
INTERCEPT_BOTH =
0x03
REWRITE_NONE =
0x00
REWRITE_REQUEST =
0x01
REWRITE_RESPONSE =
0x02
REWRITE_BOTH =
0x04
INTERCEPT_DEFAULT_PORT =
8081
MODE_REGULAR =
0x01
MODE_TRANSPARENT =
0x02

Class Method Summary collapse

Class Method Details

.active?Boolean

Returns:

  • (Boolean)


94
95
96
97
# File 'lib/watobo/core/interceptor.rb', line 94

def self.active?
  return false if @proxy.nil?
  return true
end

.intercept_modeObject



61
62
63
# File 'lib/watobo/core/interceptor.rb', line 61

def self.intercept_mode
  @intercept_mode
end

.intercept_mode=(mode) ⇒ Object



65
66
67
# File 'lib/watobo/core/interceptor.rb', line 65

def self.intercept_mode=(mode)
  @intercept_mode = mode
end

.intercept_requests?Boolean

Returns:

  • (Boolean)


74
75
76
77
# File 'lib/watobo/core/interceptor.rb', line 74

def self.intercept_requests?
  return true if ( @intercept_mode & INTERCEPT_REQUEST ) > 0
  return false
end

.intercept_responses?Boolean

Returns:

  • (Boolean)


79
80
81
82
# File 'lib/watobo/core/interceptor.rb', line 79

def self.intercept_responses?
  return true if ( @intercept_mode & INTERCEPT_RESPONSE ) > 0
  return false
end

.proxyObject



115
116
117
# File 'lib/watobo/core/interceptor.rb', line 115

def self.proxy
  @proxy
end

.proxy_modeObject



45
46
47
# File 'lib/watobo/core/interceptor.rb', line 45

def self.proxy_mode
  @proxy_mode
end

.proxy_mode=(mode) ⇒ Object



49
50
51
# File 'lib/watobo/core/interceptor.rb', line 49

def self.proxy_mode=(mode)
  @proxy_mode = mode
end

.rewrite_modeObject



53
54
55
# File 'lib/watobo/core/interceptor.rb', line 53

def self.rewrite_mode
  @rewrite_mode
end

.rewrite_mode=(mode) ⇒ Object



57
58
59
# File 'lib/watobo/core/interceptor.rb', line 57

def self.rewrite_mode=(mode)
  @rewrite_mode = mode
end

.rewrite_requests?Boolean

Returns:

  • (Boolean)


84
85
86
87
# File 'lib/watobo/core/interceptor.rb', line 84

def self.rewrite_requests?
  return true if ( @rewrite_mode & REWRITE_REQUEST ) > 0
  return false
end

.rewrite_responses?Boolean

Returns:

  • (Boolean)


89
90
91
92
# File 'lib/watobo/core/interceptor.rb', line 89

def self.rewrite_responses?
  return true if ( @rewrite_mode & REWRITE_RESPONSE ) > 0
  return false
end

.startObject



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/watobo/core/interceptor.rb', line 99

def self.start
  @proxy = Watobo::InterceptProxy.new()

  @proxy.subscribe(:new_interception) { |chat|
    Thread.new(chat) { |c|
      Watobo.project.addChat(c) unless Watobo.project.nil?
    }
  }

  @proxy.start()
  puts "DEBUG: Proxy running" if $DEBUG
  #   puts "* set www_auth for interceptor"
  #   puts YAML.dump(@project.settings[:www_auth])
  #@proxy.www_auth = Watobo.project.settings[:www_auth] unless Watobo.project.nil?
end

.stopObject



119
120
121
122
# File 'lib/watobo/core/interceptor.rb', line 119

def self.stop
  @proxy.stop
  @proxy = nil
end

.transparent?Boolean

Returns:

  • (Boolean)


69
70
71
72
# File 'lib/watobo/core/interceptor.rb', line 69

def self.transparent?
  return true if ( @proxy_mode & MODE_TRANSPARENT ) > 0
  return false
end