Skip to content
Snippets Groups Projects
Commit 9184845f authored by Konstantinos Sideris's avatar Konstantinos Sideris
Browse files

Specify option for https port

parent 30cd8636
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ synapse:
@./.ci/adjust-config.sh
@docker run -d \
--name synapse \
-p 443:8448 -p 80:8008 -p 3478:3478 \
-p 443:8448 -p 8448:8448 \
-v `pwd`/data:/data ${SYNAPSE_IMAGE} start
@echo Waiting for synapse to start...
@sleep 5
......
......@@ -10,9 +10,10 @@
using namespace mtx::client;
using namespace boost::beast;
Client::Client(const std::string &server)
Client::Client(const std::string &server, uint16_t port)
: resolver_{ios_}
, server_{server}
, port_{port}
{
work_.reset(new boost::asio::io_service::work(ios_));
......@@ -139,7 +140,7 @@ void
Client::do_request(std::shared_ptr<Session> s)
{
resolver_.async_resolve(server_,
"443",
std::to_string(port_),
std::bind(&Client::on_resolve,
shared_from_this(),
s,
......
......@@ -40,7 +40,7 @@ to_string(PaginationDirection dir)
class Client : public std::enable_shared_from_this<Client>
{
public:
Client(const std::string &server = "");
Client(const std::string &server = "", uint16_t port = 443);
//! Wait for the client to close.
void close();
......@@ -240,6 +240,8 @@ private:
mtx::identifiers::User user_id_;
//! The token that will be used as the 'since' parameter on the next sync request.
std::string next_batch_token_;
//! The homeserver port to connect.
uint16_t port_ = 443;
};
}
}
......
......@@ -2,10 +2,30 @@
#include <iostream>
#include "client.hpp"
#include "errors.hpp"
#include "mtx/responses.hpp"
using namespace mtx::client;
TEST(Basic, Connection) {}
using namespace std;
TEST(Basic, Failure) {}
using ErrType = std::experimental::optional<errors::ClientError>;
TEST(Basic, Connection)
{
auto alice = std::make_shared<Client>("localhost", 8448);
auto bob = std::make_shared<Client>("localhost", 443);
alice->versions([](const mtx::responses::Versions &, ErrType err) { ASSERT_FALSE(err); });
bob->versions([](const mtx::responses::Versions &, ErrType err) { ASSERT_FALSE(err); });
bob->close();
alice->close();
}
TEST(Basic, Failure)
{
auto alice = std::make_shared<Client>("not-resolvable-example-domain.wrong");
alice->versions([](const mtx::responses::Versions &, ErrType err) { ASSERT_TRUE(err); });
alice->close();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment