00001
00002
00003
00004
00005
00006
00008 #ifndef CPPCMS_FORWARDER_H
00009 #define CPPCMS_FORWARDER_H
00010
00011 #include <cppcms/defs.h>
00012 #include <booster/hold_ptr.h>
00013 #include <booster/shared_ptr.h>
00014 #include <booster/noncopyable.h>
00015 #include <booster/thread.h>
00016 #include <string>
00017 #include <map>
00018
00019 namespace cppcms {
00020 class mount_point;
00021 namespace http {
00022 class context;
00023 }
00024
00031 class CPPCMS_API forwarder {
00032 public:
00034 forwarder();
00035 ~forwarder();
00036
00037 typedef std::pair<std::string,int> address_type;
00038 address_type check_forwading_rules(std::string const &h,std::string const &s,std::string const &p);
00039 address_type check_forwading_rules(char const *h,char const *s,char const *p);
00040
00042
00046 void add_forwarding_rule(booster::shared_ptr<mount_point> p,std::string const &ip,int port);
00050 void remove_forwarding_rule(booster::shared_ptr<mount_point> p);
00051
00052 private:
00053 typedef std::map<booster::shared_ptr<mount_point> ,address_type> rules_type;
00054 rules_type rules_;
00055 booster::shared_mutex mutex_;
00056 struct _data;
00057 booster::hold_ptr<_data> d;
00058 };
00059
00070 void CPPCMS_API forward_connection(booster::shared_ptr<http::context> cont,std::string const &ip,int port);
00071 }
00072
00073
00074
00075 #endif