Changeset 377

Show
Ignore:
Timestamp:
05/12/08 23:44:26 (8 months ago)
Author:
tomoyo
Message:

プロクシの設定が正しく動作していなかったのを修正した。

Location:
TwitterIrcGateway
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • TwitterIrcGateway/TwitterIrcGatewayCLI/Program.cs

    r376 r377  
    1919            IPAddress bindAddress = IPAddress.Loopback; 
    2020            Encoding encoding = Encoding.GetEncoding("ISO-2022-JP"); 
     21            IWebProxy proxy = WebProxy.GetDefaultProxy(); 
    2122 
    2223            CommandLineOptions options; 
     
    3132                // Listening IP 
    3233                if (!IPAddress.TryParse(options.BindAddress, out bindAddress)) 
     34                { 
     35                    ShowUsage(); 
     36                    return; 
     37                } 
     38 
     39                // Proxy 
     40                try 
     41                { 
     42                    if (!String.IsNullOrEmpty(options.Proxy)) 
     43                        proxy = new WebProxy(options.Proxy); 
     44                } 
     45                catch (UriFormatException) 
    3346                { 
    3447                    ShowUsage(); 
     
    6073            _server.BroadcastUpdateMessageIsNotice = options.BroadcastUpdateMessageIsNotice; 
    6174            _server.SessionStartedRecieved += new EventHandler<SessionStartedEventArgs>(_server_SessionStartedRecieved); 
    62             _server.Proxy = new WebProxy(options.Proxy); 
     75            _server.Proxy = proxy; 
    6376 
    6477            Console.WriteLine("Start TwitterIrcGateway Server v{0}", typeof(Server).Assembly.GetName().Version); 
     
    8093            Console.WriteLine("[Configuration] ClientMessageWait: {0}", _server.ClientMessageWait); 
    8194            Console.WriteLine("[Configuration] BroadcatUpdateMessageIsNotice: {0}", _server.BroadcastUpdateMessageIsNotice); 
    82             Console.WriteLine("[Configuration] Proxy: {0}", _server.Proxy); 
     95            Console.WriteLine("[Configuration] Proxy: {0}", options.Proxy); 
    8396 
    8497            _server.Start(bindAddress, options.Port); 
     
    176189 
    177190        [DefaultValue("")] 
    178         [Description("web proxy url")] 
     191        [Description("HTTP proxy server URL (http://host:port)")] 
    179192        public String Proxy { get; set; } 
    180193    } 
  • TwitterIrcGateway/TwitterIrcGatewayCore/TwitterService.cs

    r376 r377  
    1717    public class TwitterService : IDisposable 
    1818    { 
    19         private WebClient _webClient; 
     19        //private WebClient _webClient; 
    2020        private CredentialCache _credential; 
     21        private IWebProxy _proxy; 
    2122        private String _userName; 
    2223        private Boolean _cookieLoginMode = false; 
     
    3637            _userName = userName; 
    3738 
    38             _webClient = new PreAuthenticatedWebClient(); 
    39             _webClient = new WebClient(); 
    40             _webClient.Credentials = _credential; 
     39            //_webClient = new PreAuthenticatedWebClient(); 
     40            //_webClient = new WebClient(); 
     41            //_webClient.Credentials = _credential; 
    4142        } 
    4243 
     
    4849            get 
    4950            { 
    50                 return _webClient.Proxy; 
     51                return _proxy; 
     52                //return _webClient.Proxy; 
    5153            } 
    5254            set 
    5355            { 
    54                 _webClient.Proxy = value; 
     56                _proxy = value; 
     57                //_webClient.Proxy = value; 
    5558            } 
    5659        } 
     
    373376        public void Dispose() 
    374377        { 
    375             if (_webClient != null) 
    376             { 
    377                 _webClient.Dispose(); 
    378                 _webClient = null; 
    379             } 
     378            //if (_webClient != null) 
     379            //{ 
     380            //    _webClient.Dispose(); 
     381            //    _webClient = null; 
     382            //} 
    380383        } 
    381384 
     
    452455            //webRequest.Credentials = _credential; 
    453456            //webRequest.PreAuthenticate = true; 
     457            webRequest.Proxy = _proxy; 
    454458            webRequest.Method = method; 
    455459            webRequest.Accept = "text/xml, application/xml"; 
     
    535539                httpRequest.Accept = "*/*"; 
    536540                httpRequest.CookieContainer = new CookieContainer(); 
     541                httpRequest.Proxy = _proxy; 
    537542                if (_cookies != null) 
    538543                {