Esempio n. 1
0
ServerEntry SessionInfo::GetServerEntry() const 
{
    if (!HasServerEntry()) {
        assert(false);
        throw std::exception("SessionInfo::GetServerEntry(): !HasServerEntry()");
    }

    // It is sometimes the case that we know more about our current server than
    // is contained in m_serverEntry or in the ServerEntry in the registry. So
    // we'll construct a new ServerEntry with the best info we have.

    ServerEntry newServerEntry(
        GetServerAddress(), GetRegion(), GetWebPort(), 
        GetWebServerSecret(), GetWebServerCertificate(), 
        GetSSHPort(), GetSSHUsername(), GetSSHPassword(), 
        GetSSHHostKey(), GetSSHObfuscatedPort(), 
        GetSSHObfuscatedKey(),
        GetMeekObfuscatedKey(), GetMeekServerPort(),
        GetMeekCookieEncryptionPublicKey(),
        GetMeekFrontingDomain(), GetMeekFrontingHost(),
        m_serverEntry.meekFrontingAddressesRegex,
        m_serverEntry.meekFrontingAddresses,
        m_serverEntry.capabilities);
    return newServerEntry;
}
Esempio n. 2
0
static void JSONSettings(const KVPairs & key_value_pairs, FILE * stream_file)
{
	ServeHeader(stream_file, 200, "OK", false, "text/plain");
	IPAddress ip;
	fprintf(stream_file, "{\n");
#ifdef ARDUINO
	ip = GetIP();
	fprintf_P(stream_file, PSTR("\t\"ip\" : \"%d.%d.%d.%d\",\n"), ip[0], ip[1], ip[2], ip[3]);
	ip = GetNetmask();
	fprintf_P(stream_file, PSTR("\t\"netmask\" : \"%d.%d.%d.%d\",\n"), ip[0], ip[1], ip[2], ip[3]);
	ip = GetGateway();
	fprintf_P(stream_file, PSTR("\t\"gateway\" : \"%d.%d.%d.%d\",\n"), ip[0], ip[1], ip[2], ip[3]);
	ip = GetNTPIP();
	fprintf_P(stream_file, PSTR("\t\"NTPip\" : \"%d.%d.%d.%d\",\n"), ip[0], ip[1], ip[2], ip[3]);
	fprintf_P(stream_file, PSTR("\t\"NTPoffset\" : \"%d\",\n"), GetNTPOffset());
#endif
	fprintf_P(stream_file, PSTR("\t\"webport\" : \"%u\",\n"), GetWebPort());
	fprintf_P(stream_file, PSTR("\t\"ot\" : \"%d\",\n"), GetOT());
	ip = GetWUIP();
	fprintf_P(stream_file, PSTR("\t\"wuip\" : \"%d.%d.%d.%d\",\n"), ip[0], ip[1], ip[2], ip[3]);
	fprintf_P(stream_file, PSTR("\t\"wutype\" : \"%s\",\n"), GetUsePWS() ? "pws" : "zip");
	fprintf_P(stream_file, PSTR("\t\"zip\" : \"%ld\",\n"), (long) GetZip());
	fprintf_P(stream_file, PSTR("\t\"sadj\" : \"%ld\",\n"), (long) GetSeasonalAdjust());
	char ak[17];
	GetApiKey(ak);
	fprintf_P(stream_file, PSTR("\t\"apikey\" : \"%s\",\n"), ak);
	GetPWS(ak);
	ak[11] = 0;
	fprintf_P(stream_file, PSTR("\t\"pws\" : \"%s\"\n"), ak);
	fprintf(stream_file, "}");
}
Esempio n. 3
0
bool web::Init()
{
	uint16_t port = GetWebPort();
	if ((port > 65000) || (port < 80))
		port = 80;
	trace(F("Listening on Port %u\n"), port), 
	m_server = new EthernetServer(port);
#ifdef ARDUINO
	m_server->begin();
	return true;
#else
	return m_server->begin();
#endif
}
/*
  Local config viewer. Supports multiple pages

*/
byte OSLocalUI::modeHandler_Viewconf(byte forceRefresh)
{
// assert
   if( osUI_Mode != OSUI_MODE_VIEWCONF )  return false;  // Basic protection to ensure current UI mode is correct

// initial setup, start from page 0
   if( forceRefresh == 2 ) osUI_Page = 0;

   char btn = get_button_async(0);

// handle input
   if( btn == BUTTON_MODE ){

       set_mode( OSUI_MODE_HOME); // change mode back to HOME (skip SETUP for now)
       return true;
   }
   else if( btn == BUTTON_UP ){

       if( osUI_Page < 3 ) osUI_Page++;
       else                         osUI_Page = 0;

       forceRefresh = 1;
   }
   else if( btn == BUTTON_DOWN ){

       if( osUI_Page > 0 ) osUI_Page--;
       else                         osUI_Page = 3;

       forceRefresh = 1;
   }

   if( forceRefresh != 0 ){   // entering VIEWCONF mode, refresh things

          lcd.clear();
          lcd.setCursor(0, 0);

          if( osUI_Page == 0 ){

             lcd_print_pgm(PSTR("Conf: Version"));
             lcd.setCursor(0,1);
             lcd_print_pgm(PSTR(VERSION));
          }
          else if( osUI_Page == 1 ){
             uint32_t ip = GetIP();

             lcd_print_pgm(PSTR("Conf: IP"));
             lcd.setCursor(0,1);
             lcd_print_ip((byte *)&ip);

          }
          else if( osUI_Page == 2 ){

             lcd_print_pgm(PSTR("Conf: Port"));
             lcd.setCursor(0,1);
             lcd.print(GetWebPort());
          }
          else if( osUI_Page == 3 ){
             uint32_t ip = GetGateway();

             lcd_print_pgm(PSTR("Conf: Gateway"));
             lcd.setCursor(0,1);
             lcd_print_ip((byte *)&ip);

          }
   }

  return true;
}