JNIEXPORT jobjectArray JNICALL Java_com_zimbra_znative_ProxyInfo_getProxyInfo(JNIEnv *env, jclass cls, jstring jurl) { check_initialized(env); CFStringRef urlstr = getCFString(env, jurl); CFURLRef url = CFURLCreateWithString(NULL, urlstr, NULL); CFDictionaryRef systemProxy = CFNetworkCopySystemProxySettings(); CFArrayRef proxyArray = CFNetworkCopyProxiesForURL(url, systemProxy); CFIndex size = CFArrayGetCount(proxyArray); jobjectArray results = (*env)->NewObjectArray(env, (jsize) size, pi_cls, NULL); int i; for (i = 0; i < size; i++) { CFDictionaryRef proxy = CFArrayGetValueAtIndex(proxyArray, i); (*env)->SetObjectArrayElement(env, results, i, getProxyInfo(env, proxy)); } CFRelease(proxyArray); CFRelease(systemProxy); CFRelease(url); CFRelease(urlstr); return results; }
DWORD CALLBACK UpdateThread(LPVOID v) { #define RSZ 30 int len; char response[RSZ], *r; char url[300]; BOOL error = FALSE; static char pbuf[8192]; char *p=NULL; *response = 0; if (getProxyInfo(pbuf)) { p=strstr(pbuf,"http="); if (!p) p=pbuf; else { p+=5; } char *tp=strstr(p,";"); if (tp) *tp=0; char *p2=strstr(p,"="); if (p2) p=0; // we found the wrong proxy } InitializeUpdate(); JNL_HTTPGet *get = new JNL_HTTPGet(g_dns,8192,(p&&p[0])?p:NULL); lstrcpyA(url,NSIS_UPDATE); lstrcatA(url,g_sdata.brandingv); lstrcpyA(response,""); get->addheader("User-Agent: MakeNSISw (jnetlib)"); get->addheader("Accept:*/*"); get->connect(url); while (1) { int st=get->run(); if (st<0) { error = TRUE; break; }//error if (get->get_status()==2) { while( (len=get->bytes_available()) ) { char b[RSZ]; if (len>RSZ) len=RSZ; if (lstrlenA(response)+len>RSZ) break; len=get->get_bytes(b,len); b[len]=0; lstrcatA(response,b); } } if (st==1) break; //closed } r = response; while (r&&*r) { if (*r=='\n') { *r = 0; break; } r++; } if (error) { char buf[1000]; wsprintfA(buf, "There was a problem checking for an update. Please try again later.\n\nError: %s",get->geterrorstr()); MessageBoxA(g_sdata.hwnd,buf,"NSIS Update",MB_OK|MB_ICONINFORMATION); } else if (*response=='1'&&lstrlenA(response)>2) { char buf[200]; wsprintfA(buf, "NSIS %s is now available. Would you like to download it now?",response+2); if (MessageBoxA(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) { ShellExecuteA(g_sdata.hwnd,"open",NSIS_DL_URL,NULL,NULL,SW_SHOWNORMAL); } } else if (*response=='2'&&lstrlenA(response)>2) { char buf[200]; wsprintfA(buf,"NSIS %s is now available. Would you like to download this preview release now?",response+2); if (MessageBoxA(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) { ShellExecuteA(g_sdata.hwnd,"open",NSIS_DL_URL,NULL,NULL,SW_SHOWNORMAL); } } else MessageBoxA(g_sdata.hwnd,"There is no update available for NSIS at this time.","NSIS Update",MB_OK|MB_ICONINFORMATION); delete get; EnableMenuItem(g_sdata.menu,IDM_NSISUPDATE,MF_ENABLED); return 0; }
BOOL _loginEcNaviOnBBAuth( const char *username, // (I) ユーザ名 (Yahoo! Japan ID) const char *password, // (I) パスワード char *cookie, // (I/O) クッキー size_t *cookieSize // (I/O) クッキー文字列長 ) { BOOL ret = FALSE; const char *target = "http://buzzurl.jp/"; char address[MAX_WEBPAGENAME]; char *p; char *buffer = (char *)malloc( MAX_CONTENT_SIZE * 16 ); *cookie = NUL; if ( !buffer ) return ( ret ); // proxy 情報取得 setConfirmProxyInfoFunc( (CONF_FUNC)(-1) ); proxyInfoForBBAuth.useProxy = FALSE; proxyInfoForBBAuth.proxyServer[0] = NUL; proxyInfoForBBAuth.proxyPort = 0; proxyInfoForBBAuth.proxyUserName[0] = NUL; proxyInfoForBBAuth.proxyPassword[0] = NUL; getProxyInfo( &(proxyInfoForBBAuth.useProxy), proxyInfoForBBAuth.proxyServer, &(proxyInfoForBBAuth.proxyPort), proxyInfoForBBAuth.proxyUserName, proxyInfoForBBAuth.proxyPassword ); // 複数ユーザで同一PCを使っている場合もあり得るので、ログイン状態であれば // 念のためにいったんログアウトしておく _httpGetIC( target, buffer, FALSE, TRUE ); p = strstr( buffer, "/config/logout" ); if ( p ) { // Buzzurl からログアウトする _httpGetIC( "http://buzzurl.jp/config/logout", buffer, FALSE, TRUE ); // クッキーを削除 cookie[0] = NUL; InternetSetCookie( target, NULL, cookie ); } // Yahoo! Japan からログアウトする logoutYahooJapan( buffer ); // Buzzurl向けBBAuth開始URLを取得 getLoginAddressOnYahooJapan( "https://buzzurl.jp/config/login?" "done=http%3A%2F%2Fbuzzurl.jp%2F", buffer, address, TRUE ); // BBAuth 開始 _httpGetIC( address, buffer, FALSE, TRUE ); if ( *buffer ) { doYahooStep1( buffer, target, username, password, cookie, cookieSize ); if ( *cookie ) ret = TRUE; } translateURL( NULL ); free( buffer ); return ( ret ); }
BOOL _loginNewsingOnBBAuth( const char *username, // (I) ユーザ名 (Yahoo! Japan ID) const char *password, // (I) パスワード char *cookie, // (I/O) クッキー size_t *cookieSize // (I/O) クッキー文字列長 ) { BOOL ret = FALSE; const char *target = "http://newsing.jp/"; char address[MAX_WEBPAGENAME]; char *p; char *buffer = (char *)malloc( MAX_CONTENT_SIZE * 16 ); BOOL done = FALSE; int retry = 5; *cookie = NUL; if ( !buffer ) return ( ret ); // proxy 情報取得 setConfirmProxyInfoFunc( (CONF_FUNC)(-1) ); proxyInfoForBBAuth.useProxy = FALSE; proxyInfoForBBAuth.proxyServer[0] = NUL; proxyInfoForBBAuth.proxyPort = 0; proxyInfoForBBAuth.proxyUserName[0] = NUL; proxyInfoForBBAuth.proxyPassword[0] = NUL; getProxyInfo( &(proxyInfoForBBAuth.useProxy), proxyInfoForBBAuth.proxyServer, &(proxyInfoForBBAuth.proxyPort), proxyInfoForBBAuth.proxyUserName, proxyInfoForBBAuth.proxyPassword ); // 複数ユーザで同一PCを使っている場合もあり得るので、ログイン状態であれば // 念のためにいったんログアウトしておく _httpGetIC( target, buffer, FALSE, TRUE ); p = strstr( buffer, "/logout\">" ); if ( p ) { // newsing からログアウトする _httpGetIC( "http://newsing.jp/logout", buffer, FALSE, TRUE ); // クッキーを削除 // cookie[0] = NUL; // InternetSetCookie( target, NULL, cookie ); } done = FALSE; do { // Yahoo! Japan からログアウトする logoutYahooJapan( buffer ); // Sleep( 10000 ); // newsing向けBBAuth開始URLを取得 getLoginAddressOnYahooJapan( "http://newsing.jp/login", buffer, address, FALSE ); // BBAuth 開始 _httpGetIC( address, buffer, FALSE, FALSE ); if ( strstr( buffer, sjis2euc("パスワードの再確認") ) ) { char *request = (char *)malloc( RCV_BUFFER_SIZE ); if ( request ) { doYahooStep1a( buffer, request, target, username, password, cookie, cookieSize ); free( request ); if ( *cookie ) break; } retry--; if ( retry <= 0 ) break; } else done = TRUE; } while ( !done ); if ( done ) if ( !(*cookie) ) doYahooStep1( buffer, target, username, password, cookie, cookieSize ); if ( *cookie ) ret = TRUE; translateURL( NULL ); free( buffer ); return ( ret ); }
void test_primenet (void) { int m_primenet, m_dialup; unsigned long m_proxy_port, m_debug; char m_userid[21], m_compid[21], m_proxy_host[121]; char m_proxy_user[51], m_proxy_pwd[51], orig_proxy_pwd[51]; unsigned short proxy_port; int update_computer_info, primenet_debug; char m_username[81], m_userpwd[14]; update_computer_info = FALSE; primenet_debug = IniSectionGetInt (INI_FILE, "PrimeNet", "Debug", 0); m_primenet = USE_PRIMENET; if (strcmp (USERID, "ANONYMOUS") == 0) m_userid[0] = 0; else strcpy (m_userid, USERID); strcpy (m_compid, COMPID); m_dialup = DIAL_UP; getProxyInfo (m_proxy_host, &proxy_port, m_proxy_user, m_proxy_pwd); m_proxy_port = proxy_port; strcpy (orig_proxy_pwd, m_proxy_pwd); m_debug = primenet_debug; askYN ("Use PrimeNet to get work and report results", &m_primenet); if (!m_primenet) goto done; outputLongLine ("\nYou must first create your user ID at mersenne.org or leave user ID blank to run anonymously. See the readme.txt file for details.\n"); askStr ("Optional user ID", m_userid, 20); askStr ("Optional computer name", m_compid, 20); askYN ("Computer uses a dial-up connection to the Internet", &m_dialup); askStr ("Optional proxy host name", m_proxy_host, 120); if (!m_proxy_host[0]) goto done; askNum ("Proxy port number", &m_proxy_port, 1, 65535); askStr ("Optional proxy user name", m_proxy_user, 50); askStr ("Optional proxy password", m_proxy_pwd, 50); askNum ("Output debug info to prime.log (0=none, 1=some, 2=lots)", &m_debug, 0, 2); done: if (askOkCancel ()) { DIAL_UP = m_dialup; IniWriteInt (INI_FILE, "DialUp", DIAL_UP); if (m_proxy_host[0] && m_proxy_port != 8080) sprintf (m_proxy_host + strlen (m_proxy_host), ":%lu", m_proxy_port); IniSectionWriteString (INI_FILE, "PrimeNet", "ProxyHost", m_proxy_host); if (m_proxy_host[0]) { IniSectionWriteString (INI_FILE, "PrimeNet", "ProxyUser", m_proxy_user); if (strcmp (m_proxy_pwd, orig_proxy_pwd)) { IniSectionWriteString (INI_FILE, "PrimeNet", "ProxyPass", m_proxy_pwd); IniSectionWriteInt (INI_FILE, "PrimeNet", "ProxyMask", 0); } } if (m_debug != primenet_debug) { IniSectionWriteInt (INI_FILE, "PrimeNet", "Debug", m_debug); } if (m_userid[0] == 0) strcpy (m_userid, "ANONYMOUS"); if (strcmp (USERID, m_userid) != 0) { strcpy (USERID, m_userid); sanitizeString (USERID); IniWriteString (INI_FILE, "V5UserID", USERID); update_computer_info = TRUE; } if (strcmp (COMPID, m_compid) != 0) { strcpy (COMPID, m_compid); sanitizeString (COMPID); IniWriteString (LOCALINI_FILE, "ComputerID", COMPID); update_computer_info = TRUE; } if (!USE_PRIMENET && m_primenet) { USE_PRIMENET = 1; create_window (COMM_THREAD_NUM); base_title (COMM_THREAD_NUM, "Communication thread"); if (!STARTUP_IN_PROGRESS) set_comm_timers (); spoolMessage (PRIMENET_UPDATE_COMPUTER_INFO, NULL); spoolExistingResultsFile (); } else if (USE_PRIMENET && !m_primenet) { USE_PRIMENET = 0; if (!STARTUP_IN_PROGRESS) set_comm_timers (); } else if (update_computer_info) spoolMessage (PRIMENET_UPDATE_COMPUTER_INFO, NULL); IniWriteInt (INI_FILE, "UsePrimenet", USE_PRIMENET); spoolMessage (PRIMENET_PROGRAM_OPTIONS, NULL); } else STARTUP_IN_PROGRESS = 0; }