Example #1
0
 def on_shutdown(self):
     if self._ngrok_started:
         self._ngrok_disconnect()
         ngrok.kill()
Example #2
0
    def _ngrok_connect(self):
        if self._retry_connect_timer:
            self._retry_connect_timer = None

        if self._ngrok_started:
            self._ngrok_disconnect()

        if not self._settings.get(["token"]):
            self._logger.warning("Ngrok auth token is not configured")
            self._plugin_manager.send_plugin_message(
                self._identifier,
                dict(
                    error=
                    "The auth token is not configured. An auth token is required to create a secure tunnel."
                ))

            self._restart_ngrok = True
            self._attempting_connect_on_start = False

            return

        if not (self._settings.get(["auth_name"])
                and self._settings.get(["auth_pass"])):
            self._logger.warning("Basic Auth is not configured")
            self._plugin_manager.send_plugin_message(
                self._identifier,
                dict(
                    error=
                    "The username and password are not configured. Authentication is required to create a secure tunnel."
                ))
            self._attempting_connect_on_start = False

            return

        pyngrok_config = PyngrokConfig()
        pyngrok_config.log_event_callback = self.on_ngrok_log_event
        pyngrok_config.auth_token = self._settings.get(["token"])
        pyngrok_config.region = self._settings.get(["region"])

        if self._restart_ngrok:
            self._logger.info("Setting ngrok auth token & region...")
            if self._ngrok_started:
                ngrok.kill()  # Make sure no previous token is used

            # Resettimg the _restart_ngrok flag is postponed until we know the restart was succesful
            # because otherwise the token and region may not "take".

        self._logger.info("Opening ngrok tunnel...")
        options = dict(bind_tls=True,
                       inspect=False,
                       auth="%s:%s" % (self._settings.get(
                           ["auth_name"]), self._settings.get(["auth_pass"])))

        if self._settings.get(["subdomain"]):
            options["subdomain"] = self._settings.get(["subdomain"])
        if self._settings.get(["hostname"]):
            options["hostname"] = self._settings.get(["hostname"])

        try:
            if self._legacy_ngrok:
                tunnel = ngrok.connect(
                    port=self._settings.get_int(["port"]),
                    options=options,
                    pyngrok_config=pyngrok_config)  # type:str
            else:
                tunnel = ngrok.connect(addr=self._settings.get_int(["port"]),
                                       pyngrok_config=pyngrok_config,
                                       **options)  # type:NgrokTunnel
            self._ngrok_started = True
        except PyngrokNgrokError:
            self._logger.error("Could not connect with the provided API key")
            self._attempting_connect_on_start = False
            return

        self._attempting_connect_on_start = False
        if tunnel:
            if self._legacy_ngrok:
                tunnel_url = tunnel
            else:
                tunnel_url = tunnel.public_url
            self._tunnel_url = tunnel_url.partition("://")[2]
            self._logger.info("ngrok tunnel: %s" % self._tunnel_url)
            self._plugin_manager.send_plugin_message(
                self._identifier, dict(tunnel=self._tunnel_url))

            self._event_bus.fire(Events.PLUGIN_NGROK_CONNECTED,
                                 dict(tunnel=self._tunnel_url))

            self._restart_ngrok = False
Example #3
0
def stop_ngrok():
    print("Stopping `ngrok`...")
    ngrok.kill()
    print('==> Successfully started `ngrok`')
Example #4
0
url_file = "/tmp/ngrok.url"
scope = [
    'https://spreadsheets.google.com/feeds',
    'https://www.googleapis.com/auth/drive'
]
creds = ServiceAccountCredentials.from_json_keyfile_name(
    join(dirname(realpath(__file__)), google_credential_file), scope)
client = gspread.authorize(creds)
sheet = client.open("Rpi Ngrok URL").sheet1

ngrok.set_auth_token(ngrok_token)

if os.path.exists(url_file):
    os.remove(url_file)
with open(url_file, "w") as f:
    ssh_tunnel = ngrok.connect(22, "tcp")
    url = ssh_tunnel.public_url
    print(url)

    f.write(url + "\n")
    sheet.update("A1", url)
    sheet.update("B1", datetime.now().strftime("%Y-%m-%d %H:%M:%S"))

print("Successfuly created a tunnel")
ngrok_process = ngrok.get_ngrok_process()
try:
    ngrok_process.proc.wait()
except KeyboardInterrupt:
    print("Shutting down server")
    ngrok.kill()
Example #5
0
 def stop(self):
     if self.connected:
         ngrok.kill()
         if self.webhook_server:
             self.webhook_server.stop()
Example #6
0
    def __init__(self,
                 clone=None,
                 dock=None,
                 media=None,
                 sqlimport=None,
                 copy=None,
                 sqlexport=None,
                 flush=None,
                 path=None,
                 bam=None,
                 action=None,
                 rok=None):
        for i in range(0, 101):
            if i % self._progressEveryPercent == 0:
                self._progressDict[str(i)] = ""
        if os.getenv("GIT_USER") and os.getenv("GIT_PASS") and os.getenv(
                "SSH_USER") and os.getenv("SSH_PASS"):
            # click.echo(click.style('All rigthooo !', fg='green'))
            self._credentials.get("atlassian")["user"] = os.getenv(
                "ATLASSIAN_USER")
            self._credentials.get("atlassian")["pass"] = os.getenv(
                "ATLASSIAN_PASS")
            self._credentials.get("rok")["api"] = os.getenv("ROK_API")
            self._credentials.get("git")["user"] = os.getenv("GIT_USER")
            self._credentials.get("git")["pass"] = os.getenv("GIT_PASS")
            self._credentials.get("git_bucket")["user"] = os.getenv(
                "GIT_BUCKET_USER")
            self._credentials.get("git_bucket")["pass"] = os.getenv(
                "GIT_BUCKET_PASS")
            self._credentials.get("ssh")["user"] = os.getenv("SSH_USER")
            self._credentials.get("ssh")["pass"] = os.getenv("SSH_PASS")
            self._repos = {
                "flow": {
                    "main":
                    "http://%s:%[email protected]:7990/scm/fb/flowbusiness_co.git"
                    % (self._credentials.get("git")["user"],
                       self._credentials.get("git")["pass"]),
                    "bb":
                    "http://%s:%[email protected]:7990/scm/fb/sites_flowbusiness_bb.git"
                    % (self._credentials.get("git")["user"],
                       self._credentials.get("git")["pass"]),
                    "panama":
                    "http://%s:%[email protected]:7990/scm/fb/sites_masmovilpanama_negocios.git"
                    % (self._credentials.get("git")["user"],
                       self._credentials.get("git")["pass"]),
                    "trinidad":
                    "http://%s:%[email protected]:7990/scm/fb/sites_flowbusiness_tt.git"
                    % (self._credentials.get("git")["user"],
                       self._credentials.get("git")["pass"]),
                    "jamaica":
                    "http://%s:%[email protected]:7990/scm/fb/sites_flowbusiness_jm.git"
                    % (self._credentials.get("git")["user"],
                       self._credentials.get("git")["pass"]),
                    "flow":
                    "https://%s:%[email protected]/scm/fb/flow-business.git"
                    % (self._credentials.get("git_bucket")["user"],
                       self._credentials.get("git_bucket")["pass"])
                },
                "cw": {
                    "net":
                    "http://%s:%[email protected]:7990/scm/cwnet/core.git"
                    % (self._credentials.get("git")["user"],
                       self._credentials.get("git")["pass"]),
                    "bus":
                    "http://%s:%[email protected]:7990/scm/cwcbus/core.git"
                    % (self._credentials.get("git")["user"],
                       self._credentials.get("git")["pass"]),
                }
            }
            if bam:
                bamboo = Bamboo(
                    url=self._credentials.get("atlassian")["url"],
                    username=self._credentials.get("atlassian")["user"],
                    password=self._credentials.get("atlassian")["pass"],
                    advanced_mode=True)
                if bam == "panama":
                    if action == 'build':
                        plan = bamboo.get_plan('CMS-SITCWPNEG')
                        the_build = bamboo.execute_build(
                            plan_key=plan.json().get('key'))
                        click.echo(
                            click.style('Build execution status: {}'.format(
                                the_build.status_code),
                                        fg='green'))
                        if the_build.status_code == 200:
                            click.echo(
                                click.style("Build key: {}".format(
                                    the_build.json().get("buildResultKey")),
                                            fg='green'))
                            click.echo(
                                click.style(the_build.json().get(
                                    "link", {}).get('href'),
                                            fg='green'))
                        else:
                            click.echo(
                                click.style("Execution failed!", fg='red'))
                            click.echo(
                                click.style(the_build.json().get("message"),
                                            fg='red'))
                    elif action == 'deploy':
                        res = requests.get(
                            'https://bamboo-qa.cwc-apps.com/rest/api/latest/deploy/project/all',
                            auth=(self._credentials.get("atlassian")["user"],
                                  self._credentials.get("atlassian")["pass"]))
                        resDep = requests.get(
                            'https://bamboo-qa.cwc-apps.com/rest/api/latest/deploy/project/9797640/versions',
                            auth=(self._credentials.get("atlassian")["user"],
                                  self._credentials.get("atlassian")["pass"]))
                        releaseName = 'release-{}'.format(
                            int(resDep.json()['versions'][0]['name'].replace(
                                'release-', '')) + 1)
                        planResultNum = resDep.json()['versions'][0]['items'][
                            0]['planResultKey']['resultNumber'] + 1
                        planResultKey = '{}-{}'.format(
                            resDep.json()['versions'][0]['items'][0]
                            ['planResultKey']['entityKey']['key'],
                            planResultNum)
                        job = requests.post(
                            'https://bamboo-qa.cwc-apps.com/rest/api/latest/deploy/project/9797640/version',
                            auth=(self._credentials.get("atlassian")["user"],
                                  self._credentials.get("atlassian")["pass"]),
                            json={
                                "planResultKey": planResultKey,
                                "name": releaseName
                            },
                            headers={
                                "Content-Type": "application/json",
                                "Accepts": "application/json"
                            })
                        for item in res.json():
                            if 'planKey' in item:
                                # Name: CW Panama Negocios - QAT key: 9797635
                                # Name: CW Panama Negocios - STG key: 9797638
                                # Name: CW Panama Negocios - PRD key: 9797640
                                # IN THIS CASE I WANT TO USE PROD
                                if item['planKey'][
                                        'key'] == 'CMS-SITCWPNEG' and item[
                                            'key']['key'] == '9797640':
                                    for env in item['environments']:
                                        releaseJob = requests.post(
                                            'https://bamboo-qa.cwc-apps.com/rest/api/latest/queue/deployment/?environmentId={}&versionId={}'
                                            .format(env['id'],
                                                    job.json()['id']),
                                            auth=(self._credentials.get(
                                                "atlassian")["user"],
                                                  self._credentials.get(
                                                      "atlassian")["pass"]),
                                            headers={
                                                "Accepts": "application/json"
                                            })
                                        print(releaseJob.text)
                                        click.echo(
                                            click.style(
                                                "ENVIRONMENT RELEASED: {}".
                                                format(env['name']),
                                                fg='green'))
            if clone:
                click.echo(click.style('Cloning %s' % (clone), fg='green'))
                if clone == "panama":
                    url = self._repos.get("flow")[clone]
                    path = "%s/sites/negocios.masmovilpanama.com" % (
                        self._cloneDirs.get("flow"))
                    click.echo(click.style('clone url %s' % (url), fg='green'))
                    self.gitClone(url, path)
                elif clone == "main":
                    url = self._repos.get("flow")[clone]
                    path = "%s" % (self._cloneDirs.get("flow"))
                    click.echo(click.style('clone url %s' % (url), fg='green'))
                    self.gitClone(url, path)
                elif clone == "bb":
                    url = self._repos.get("flow")[clone]
                    path = "%s/sites/flowbusiness.co.barbados" % (
                        self._cloneDirs.get("flow"))
                    click.echo(click.style('clone url %s' % (url), fg='green'))
                    self.gitClone(url, path)
                elif clone == "trinidad":
                    url = self._repos.get("flow")[clone]
                    path = "%s/sites/flowbusiness.co.trinidad-and-tobago" % (
                        self._cloneDirs.get("flow"))
                    click.echo(click.style('clone url %s' % (url), fg='green'))
                    self.gitClone(url, path)
                elif clone == "jamaica":
                    url = self._repos.get("flow")[clone]
                    path = "%s/sites/flowbusiness.co.jamaica" % (
                        self._cloneDirs.get("flow"))
                    click.echo(click.style('clone url %s' % (url), fg='green'))
                    self.gitClone(url, path)
                elif clone == "net":
                    url = self._repos.get("cw")[clone]
                    path = "%s" % (self._cloneDirs.get("cwnet"))
                    click.echo(click.style('clone url %s' % (url), fg='green'))
                    self.gitClone(url, path)
                elif clone == "bus":
                    url = self._repos.get("cw")[clone]
                    path = "%s" % (self._cloneDirs.get("flow"))
                    click.echo(click.style('clone url %s' % (url), fg='green'))
                    self.gitClone(url, path)
                elif clone == "flow":
                    url = self._repos.get("flow")[clone]
                    path = "%s" % (self._cloneDirs.get("flowb"))
                    click.echo(click.style('clone url %s' % (url), fg='green'))
                    self.gitClone(url, path)
            if dock:
                if dock == "php":
                    subprocess.run([
                        "docker-compose", "-f",
                        "../liberty_docker/php/docker-compose.yaml", "up",
                        "-d", "--build"
                    ])
                    click.echo(click.style('Done Docker', fg='green'))
                elif dock == "mysql":
                    subprocess.run([
                        "docker-compose", "-f",
                        "../liberty_docker/mysql/docker-compose.yaml", "up",
                        "-d", "--build"
                    ])
                    click.echo(click.style('Done Docker', fg='green'))
                elif dock == "apache":
                    subprocess.run([
                        "docker-compose", "-f",
                        "../liberty_docker/apache/docker-compose.yaml", "up",
                        "-d", "--build"
                    ])
                    click.echo(click.style('Done Docker', fg='green'))
                elif dock == "composer":
                    subprocess.run([
                        "docker-compose", "-f",
                        "../liberty_docker/php/docker-compose.yaml", "run",
                        "--rm", "cw-php", "composer", "install"
                    ])
                    click.echo(click.style('Done Docker', fg='green'))
            if sqlimport:
                if sqlimport == "panama":
                    self.sqlImport("c_", "negocios_masmovilpanama_com")
                if sqlimport == "vlocity":
                    self.sqlImport("g_", "masmovilpanama_velocity")
                if sqlimport == "flow":
                    self.sqlImport("f_", "flowbusiness_co")
                elif sqlimport == "trinidad":
                    self.sqlImport("e_", "flowbusiness_tt")
                elif sqlimport == "barbados":
                    self.sqlImport("b_", "flowbusiness_bb")
                elif sqlimport == "bus":
                    self.sqlImport("d_", "cwcbusin_wp")
                elif sqlimport == "curacao":
                    self.sqlImport("i_", "flowbusiness_cw")
                elif sqlimport == "init_curacao":
                    self.sqlImport("i_a_", "init")
                elif sqlimport == "eastern":
                    self.sqlImport("j_", "flowbusiness_ec")
                elif sqlimport == "init_eastern":
                    self.sqlImport("j_a_", "init")
            if sqlexport:
                if sqlexport == "panama":
                    self.sqlExport("c_", "negocios_masmovilpanama_com")
                if sqlexport == "vlocity":
                    self.sqlExport("g_", "masmovilpanama_velocity")
                elif sqlexport == "bus":
                    self.sqlExport("d_", "cwcbusin_wp")
                elif sqlexport == "trinidad":
                    self.sqlExport("e_", "flowbusiness_tt")
                elif sqlexport == "bb":
                    self.sqlExport("b_", "flowbusiness_bb")
                elif sqlexport == "jamaica":
                    self.sqlExport("h_", "flowbusiness_jm")
                elif sqlexport == "curacao":
                    self.sqlExport("i_", "flowbusiness_cw")
                elif sqlexport == "eastern":
                    self.sqlExport("i_", "flowbusiness_ec")
            if media:
                if media == "panama":
                    if path is None:
                        path = "files"
                    print('path')
                    print(path)
                    self.downloadDir(
                        "/var/www/html/flowbusiness.co/sites/negocios.masmovilpanama.com",
                        os.path.join(self._cloneDirs.get("flowb"), "web",
                                     "sites", "negocios.masmovilpanama.com"),
                        "10.255.229.14", path)
                elif media == "trinidad":
                    if path is None:
                        path = "files"
                    print("ptah", path)
                    print(
                        os.path.join(self._cloneDirs.get("flow"), "sites",
                                     "flowbusiness.co.trinidad-and-tobago"))
                    self.downloadDir(
                        "/var/www/html/flowbusiness.co/sites/flowbusiness.co.trinidad-and-tobago",
                        os.path.join(self._cloneDirs.get("flowb"), "web",
                                     "sites",
                                     "flowbusiness.co.trinidad-and-tobago"),
                        "10.255.229.14", path)
                elif media == "jamaica":
                    if path is None:
                        path = "files"
                    print("ptah", path)
                    print(
                        os.path.join(self._cloneDirs.get("flow"), "sites",
                                     "flowbusiness.co.jamaica"))
                    self.downloadDir(
                        "/var/www/html/flowbusiness.co/sites/flowbusiness.co.jamaica",
                        os.path.join(self._cloneDirs.get("flowb"), "web",
                                     "sites", "flowbusiness.co.jamaica"),
                        "10.255.229.14", path)
                elif media == "curacao":
                    if path is None:
                        path = "files"
                    print("ptah", path)
                    print(
                        os.path.join(self._cloneDirs.get("flow"), "sites",
                                     "flowbusiness.co.curacao"))
                    self.downloadDir(
                        "/var/www/html/flowbusiness.co/sites/flowbusiness.co.curacao",
                        os.path.join(self._cloneDirs.get("flowb"), "web",
                                     "sites", "flowbusiness.co.curacao"),
                        "10.255.229.14", path)

                elif media == "eastern":
                    if path is None:
                        path = "files"
                    print("ptah", path)
                    print(
                        os.path.join(self._cloneDirs.get("flow"), "sites",
                                     "flowbusiness.co.eastern-caribbean"))
                    self.downloadDir(
                        "/var/www/html/flowbusiness.co/sites/flowbusiness.co.eastern-caribbean",
                        os.path.join(self._cloneDirs.get("flowb"), "web",
                                     "sites",
                                     "flowbusiness.co.eastern-caribbean"),
                        "10.255.229.14", path)

                elif media == "bus":
                    if path is None:
                        path = "uploads"
                    print(path)
                    self.downloadDir(
                        "/var/www/html/cwcbusiness/wp-content",
                        os.path.join(self._cloneDirs.get("bus"), "wp-content"),
                        "10.255.229.17", path)
            if rok:
                if rok != None:
                    ngrok.set_auth_token(self._credentials.get("rok")["api"])
                    http_tunnel = ngrok.connect()
                    ngrok_process = ngrok.get_ngrok_process()
                    try:
                        # Block until CTRL-C or some other terminating event
                        click.echo(
                            click.style('Summoning server !', fg='yellow'))
                        tunnels = ngrok.get_tunnels()
                        with open(r'./drupal-source/sites.yml',
                                  encoding="utf-8") as file:
                            data = yaml.load(file, Loader=yaml.FullLoader)
                        f = open("./flow-business/web/sites/sites.php", "w")
                        f.write("<?php\n")
                        f.write("$sites = array(\n")
                        for key in data["sites"]:
                            f.write("'{}' => '{}',\n".format(
                                key, data["sites"][key]))
                        route = None
                        if rok == "panama":
                            route = "negocios.masmovilpanama.com"
                        elif rok == "trinidad":
                            route = "flowbusiness.co.trinidad-and-tobago"
                        elif rok == "jamaica":
                            route = "flowbusiness.co.jamaica"
                        elif rok == "barbados":
                            route = "flowbusiness.co.barbados"
                        if route != None:
                            f.write("'{}' => '{}',\n".format(
                                tunnels[0].public_url.replace("https://", ""),
                                route))
                        f.write(");\n")
                        f.close()
                        click.echo(
                            click.style('Ready to rock !',
                                        blink=True,
                                        fg='green'))
                        click.echo(
                            click.style('Live on: {}'.format(
                                tunnels[0].public_url),
                                        fg='green'))
                        ngrok_process.proc.wait()
                    except KeyboardInterrupt:
                        click.echo(click.style('Server KILLED !', fg='red'))
                        ngrok.kill()
            if copy:
                flowDir = self._cloneDirs.get("flowb")
                if copy == "sites":
                    with open(r'./drupal-source/sites.yml',
                              encoding="utf-8") as file:
                        data = yaml.load(file, Loader=yaml.FullLoader)
                    f = open("./flow-business/web/sites/sites.php", "w")
                    f.write("<?php\n")
                    f.write("$sites = array(\n")
                    for key in data["sites"]:
                        f.write("'{}' => '{}',\n".format(
                            key, data["sites"][key]))
                    f.write(");\n")
                    f.close()
                elif copy == "panama":
                    # shutil.copy("./drupal-source/%s/settings.php" % (copy), os.path.join(flowDir, "web", "sites", "negocios.masmovilpanama.com", "settings.php"))
                    shutil.copy(
                        "./drupal-source/services.yml",
                        os.path.join(flowDir, "web", "sites",
                                     "negocios.masmovilpanama.com",
                                     "services.yml"))
                elif copy == "trinidad":
                    # shutil.copy("./drupal-source/%s/settings.php" % (copy), os.path.join(flowDir, "web", "sites", "flowbusiness.co.trinidad-and-tobago", "settings.php"))
                    shutil.copy(
                        "./drupal-source/services.yml",
                        os.path.join(flowDir, "web", "sites",
                                     "flowbusiness.co.trinidad-and-tobago",
                                     "services.yml"))
                elif copy == "jamaica":
                    # shutil.copy("./drupal-source/%s/settings.php" % (copy), os.path.join(flowDir, "sites", "flowbusiness.co.jamaica", "settings.php"))
                    shutil.copy(
                        "./drupal-source/services.yml",
                        os.path.join(flowDir, "web", "sites",
                                     "flowbusiness.co.jamaica",
                                     "services.yml"))
                elif copy == "barbados":
                    # shutil.copy("./drupal-source/%s/settings.php" % (copy), os.path.join(flowDir, "web", "sites", "flowbusiness.co.barbados", "settings.php"))
                    shutil.copy(
                        "./drupal-source/services.yml",
                        os.path.join(flowDir, "web", "sites",
                                     "flowbusiness.co.barbados",
                                     "services.yml"))
                elif copy == "bus":
                    shutil.copy(
                        "./wp-source/business/.htaccess",
                        os.path.join(self._cloneDirs.get("bus"), ".htaccess"))
                    shutil.copy(
                        "./wp-source/business/wp-config.php",
                        os.path.join(self._cloneDirs.get("bus"),
                                     "wp-config.php"))
                elif copy == "net":
                    shutil.copy(
                        "./wp-source/net/.htaccess",
                        os.path.join(self._cloneDirs.get("cwnet"),
                                     ".htaccess"))
                    shutil.copy(
                        "./wp-source/net/wp-config.php",
                        os.path.join(self._cloneDirs.get("cwnet"),
                                     "wp-config.php"))
            if flush:
                print('flush')
                if flush == "panama":
                    # docker-compose -f ../liberty_docker/php/docker-compose.yaml run --rm  cw-php vendor/bin/drush --uri=flowpanama.com  cache-rebuild -vvv
                    subprocess.run([
                        "docker-compose", "-f",
                        "../liberty_docker/php/docker-compose.yaml", "run",
                        "--rm", "cw-php", "vendor/bin/drush",
                        "--uri=flowpanama.com", "cache-rebuild", "-vvv"
                    ])
                    click.echo(click.style('Done Flush in panama', fg='green'))
                elif flush == "trinidad":
                    subprocess.run([
                        "docker-compose", "-f",
                        "../liberty_docker/php/docker-compose.yaml", "run",
                        "--rm", "cw-php", "vendor/bin/drush",
                        "--uri=flowbusiness.co.trinidad-and-tobago",
                        "cache-rebuild", "-vvv"
                    ])
                    click.echo(click.style('Done Flush in panama', fg='green'))
                elif flush == "barbados":
                    subprocess.run([
                        "docker-compose", "-f",
                        "../liberty_docker/php/docker-compose.yaml", "run",
                        "--rm", "cw-php", "vendor/bin/drush",
                        "--uri=flowbusiness.co.barbados", "cache-rebuild",
                        "-vvv"
                    ])
                    click.echo(click.style('Done Flush in panama', fg='green'))
                elif flush == "jamaica":
                    subprocess.run([
                        "docker-compose", "-f",
                        "../liberty_docker/php/docker-compose.yaml", "run",
                        "--rm", "cw-php", "vendor/bin/drush",
                        "--uri=flowbusiness.co.jamaica", "cache-rebuild",
                        "-vvv"
                    ])
                    click.echo(click.style('Done Flush in panama', fg='green'))
                elif flush == "install":
                    subprocess.run([
                        "docker-compose", "-f",
                        "../liberty_docker/php/docker-compose.yaml", "run",
                        "--rm", "cw-php", "composer require drush/drush"
                    ])
                    click.echo(click.style('Done Flush in panama', fg='green'))

        else:
            click.echo(
                click.style(
                    'Environment variables not found. Check your .env file',
                    fg='red'))
Example #7
0
    def __kill_proc():
        print(settings.NGROK_DOWN_STR)

        requests.post(settings.API_URL + settings.CLEAR_REDIS_URL, verify=False)
        ngrok.kill()
Example #8
0
 def stop(self):
     """ must stop so many things"""
     ngrok.kill()
     os.system(f"curl 127.0.0.1:{self.port}/shutdown")
     self.thread.join()
Example #9
0
def delete_connections(r):
    print("Deleteing")
    ngrok.kill()
    r.delete('ssh_conn_url')
    r.delete('vnc_conn_url')
Example #10
0
 def teardown(self):
     if self.app.config.get('ENVIRONMENT') == 'DEVELOPMENT':
         tunnels = ngrok.get_tunnels()
         for tunnel in tunnels:
             ngrok.disconnect(tunnel.public_url)
         ngrok.kill()
Example #11
0
        print(style.GREEN('[+]Saved data to log.txt'))

    else:
        print(style.GREEN("[+] {} connected again.".format(ip_)))

    return jsonify(status="success", data=data)

def main():
    if __name__ == '__main__':
        app.run(host = '0.0.0.0', port=port_)


while True:
    clear()
    banner()
    redirect = str(input(style.GREEN("\n[+]") + style.RESET("Please enter website to redirect to (Default: www.google.com):")))
    if redirect == "" :
        redirect = "www.google.com"
    print(str(style.GREEN("[+]") + style.RESET("Input error region must consist of 2 characters.")))
    print(str(style.GREEN("[+]") + style.RESET("Starting ngrok server...")))
    print(str(style.GREEN("\n[+]") + style.RESET("Send this link to your victim: {}\n").format(ngrok_link)))
    main()
    print(str(style.GREEN("[+]") + style.RESET("Closing ngrok server...")))
    print(ngrok.disconnect(ngrok_link))
    print(ngrok.kill())
    clear()
    banner()
    print(str(style.GREEN("\n[+]") + style.RESET("Thank you for using FlaskLocator.")))
    print(str(style.GREEN("[+]") + style.RESET("For more information contact me: [email protected]")))
    break
Example #12
0
import pyautogui
from pyngrok import ngrok
from pyngrok.exception import PyngrokNgrokError

from UltraSockets import Server


def get_ip_address():
    # This function opens a temporary socket that is used to find the computer's ip
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect(("8.8.8.8", 80))
    return s.getsockname()[0] + ':8080'


ngrok.kill()  # kills any running ngrok processes
# declare and assign all global variables
running = False
thread = None
server = None
host_ip = get_ip_address()  # assigns host ip to the PC's IP address on the network
chars = None
host = None
region_names = ['India', 'United States', 'Europe', 'Asia/Pacific', 'Australia', 'South America', 'Japan']
regions = ['in', 'us', 'eu', 'ap', 'au', 'sa', 'jp']


def run_server(server_host, characters):
    global server
    # starts the server, and start waiting for client connections
    server = Server(server_host, 1, 'server')
Example #13
0
def stop():
    ngrok.kill()
    os.system("pkill streamlit")