public static GoString FromBytes(byte[] value)
        {
            GoString s = new GoString();

            s.AsBytes = value;
            return(s);
        }
Beispiel #2
0
        public static GoString FromString(string value)
        {
            GoString s = new GoString();

            s.AsString = value;
            return(s);
        }
        private int onBlacklist(long handle, GoString goUrl, IntPtr categoriesPtr, int categoryLen)
        {
            int[] categories = new int[categoryLen];

            Marshal.Copy(categoriesPtr, categories, 0, categoryLen);
            Session session = new Session(handle, new Request(handle), new Response(handle));
            string  url     = goUrl.AsString;

            return(Blacklisted?.Invoke(session, url, categories) ?? 0);
        }
Beispiel #4
0
        /// <summary>
        /// Calls goproxy initalization and loads certificate and key from the specified files.
        /// </summary>
        /// <param name="portNumber"></param>
        /// <param name="certFile">string containing a path to a PEM-encoded certificate file.</param>
        /// <param name="keyFile">string containing a path to a PEM-encoded key file.</param>
        public void Init(short httpPortNumber, short httpsPortNumber, string certFile, string keyFile)
        {
            onBeforeRequestDelegate  = new ProxyNativeWrapper.CallbackDelegate(onBeforeRequest);
            onBeforeResponseDelegate = new ProxyNativeWrapper.CallbackDelegate(onBeforeResponse);

            ProxyNativeWrapper.SetOnBeforeRequestCallback(onBeforeRequestDelegate);
            ProxyNativeWrapper.SetOnBeforeResponseCallback(onBeforeResponseDelegate);

            ProxyNativeWrapper.Init(httpPortNumber, httpsPortNumber, GoString.FromString(certFile), GoString.FromString(keyFile));
        }
Beispiel #5
0
            public Header GetFirstHeader(string name)
            {
                GoString res = new GoString();

                if (RequestNativeWrapper.RequestGetFirstHeader(requestHandle, GoString.FromString(name), out res))
                {
                    return(new Header(name, res.AsString));
                }
                else
                {
                    return(null);
                }
            }
        public static GoString FromString(string value)
        {
            GoString s = new GoString();

            if (value == null)
            {
                s.AsString = "";
            }
            else
            {
                s.AsString = value;
            }
            return(s);
        }
        /// <summary>
        /// Calls goproxy initalization and loads certificate and key from the specified files.
        /// </summary>
        /// <param name="portNumber"></param>
        /// <param name="certFile">string containing a path to a PEM-encoded certificate file.</param>
        /// <param name="keyFile">string containing a path to a PEM-encoded key file.</param>
        public void Init(short httpPortNumber, short httpsPortNumber, string certFile, string keyFile)
        {
            onBeforeRequestDelegate  = new ProxyNativeWrapper.CallbackDelegate(onBeforeRequest);
            onBeforeResponseDelegate = new ProxyNativeWrapper.CallbackDelegate(onBeforeResponse);

            onBlacklistDelegate = new AdBlockMatcherApi.InternalAdBlockCallbackDelegate(onBlacklist);
            onWhitelistDelegate = new AdBlockMatcherApi.InternalAdBlockCallbackDelegate(onWhitelist);

            ProxyNativeWrapper.SetOnBeforeRequestCallback(onBeforeRequestDelegate);
            ProxyNativeWrapper.SetOnBeforeResponseCallback(onBeforeResponseDelegate);

            AdBlockMatcherApi.SetBlacklistCallback(onBlacklistDelegate);
            AdBlockMatcherApi.SetWhitelistCallback(onWhitelistDelegate);

            ProxyNativeWrapper.Init(httpPortNumber, httpsPortNumber, GoString.FromString(certFile), GoString.FromString(keyFile));
        }
 public static extern bool CreateResponse(long handle, int status, GoString contentType, GoString body);
Beispiel #9
0
 public bool HeaderExists(string name)
 {
     return(ResponsetNativeWrapper.ResponseHeaderExists(responseHandle, GoString.FromString(name)));
 }
 public static extern bool ResponseGetBodyAsString(long handle, out GoString body);
 public static extern bool ResponseGetFirstHeader(long handle, GoString name, out GoString res);
 public static extern bool ResponseHeaderExists(long handle, GoString name);
 public static extern bool RequestGetBodyAsString(long handle, out GoString body);
 public static extern int RequestGetHeaders(long handle, out GoString res);
Beispiel #15
0
 public bool HeaderExists(string name)
 {
     return(RequestNativeWrapper.RequestHeaderExists(requestHandle, GoString.FromString(name)));
 }
 public static extern int ResponseGetHeaders(long handle, out GoString res);
 public static extern void SetProxyLogFile(GoString logFile);
        public static void SetProxyLogFile(string logFile)
        {
            GoString str = GoString.FromString(logFile);

            SetProxyLogFile(str);
        }
 public static extern void Init(short httpPortNumber, short httpsPortNumber, GoString certFile, GoString keyFile);
 public static extern bool RequestGetUrl(long handle, out GoString res);
 public static extern bool RequestHeaderExists(long handle, GoString name);