当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ip.address函数代码示例

本文整理汇总了TypeScript中ip.address函数的典型用法代码示例。如果您正苦于以下问题:TypeScript address函数的具体用法?TypeScript address怎么用?TypeScript address使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了address函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

 server.start((err: any) => {
     if (err) {
         throw err;
     } else {
         console.log(`Server running at: http://${Ip.address()}:${server.info.port}`);
     }
 });
开发者ID:ARA-Tester,项目名称:ARA-Tester,代码行数:7,代码来源:index.ts

示例2: log

export async function log(log: LogInterface): Promise<boolean> {
    if (!log.userId) {
        log.userId = null;
    }

    if (!log.module) {
        log.module = '';
    }
    log.module = log.module.toLowerCase();

    if (!log.type) {
        log.type = '';
    }

    const newLog = new MoLogs();

    newLog.module = log.module;
    newLog.type = log.type;
    newLog.date = new Date();
    newLog.ip = address();
    newLog.info = log.info;
    newLog.userId = log.userId;

    await getConnection().getRepository(MoLogs).save(newLog);

    return true;
}
开发者ID:Maxtream,项目名称:themages-cms,代码行数:27,代码来源:log.ts

示例3: checkBruteForce

    private async checkBruteForce(): Promise<boolean> {
        // Remove timed out IPs
        this.timeOutAuthAttempts(true);

        try {
            // Fetching previous attempts to login
            const response = await getConnection().getRepository(MoUsersAuthAttempts)
                .findOne({
                    ip: address()
                });

            if (response && response.attempts >= this.availableLoginAttempts) {
                // Immediately trigger response as false to block off bruteforce
                return false;
            }
            if (response) {
                // In case there were already attempts, we're incrementing the attempt
                response.attempts++;
                await getConnection().getRepository(MoUsersAuthAttempts).save(response);
            } else {
                // Saving first attempt from this IP address
                const usersAuthAttempts: MoUsersAuthAttempts = new MoUsersAuthAttempts();

                usersAuthAttempts.attempts = 1;
                usersAuthAttempts.timestamp = new Date();
                usersAuthAttempts.ip = address();
                await getConnection().getRepository(MoUsersAuthAttempts).save(usersAuthAttempts);
            }

            return true;
        } catch (error) {
            return false;
        }

        return true;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:36,代码来源:login.ts

示例4: appStarted

  // Called when express.js app starts on given port w/o errors
  public static appStarted(port: number, tunnelStarted?: string) {
    console.log(`Server started ${chalk.green('✓')}`);

    // If the tunnel started, log that and the URL it's available at
    if (tunnelStarted) {
      console.log(`Tunnel initialised ${chalk.green('✓')}`);
    }

    console.log(`
${chalk.bold('Access URLs:')}${divider}
Localhost: ${chalk.magenta(`http://localhost:${port}`)}
      LAN: ${chalk.magenta(`http://${ip.address()}:${port}`) +
(tunnelStarted ? `\n    Proxy: ${chalk.magenta(tunnelStarted)}` : '')}${divider}
${chalk.blue(`Press ${chalk.italic('CTRL-C')} to stop`)}
    `);
  }
开发者ID:StrikeForceZero,项目名称:react-boilerplate,代码行数:17,代码来源:logger.ts

示例5: timeOutAuthAttempts

    private async timeOutAuthAttempts(timer: boolean = false): Promise<boolean> {
        const findByRules = {
            ip: address(),
            timestamp: null
        };

        // Just in case if we need to check by timestamp
        if (timer) {
            findByRules.timestamp = LessThan(format(subMinutes(new Date(), 5), 'YYYY-MM-DD HH:mm:ss'));
        }

        // Fetching attempts
        const response = await getConnection().getRepository(MoUsersAuthAttempts).find(findByRules);

        // Cleaning up outdated attempts
        if (response) {
            await getConnection().getRepository(MoUsersAuthAttempts).remove(response);
        }

        return true;
    }
开发者ID:Maxtream,项目名称:themages-cms,代码行数:21,代码来源:login.ts

示例6: startServerProcess

import child_process from 'child_process';
import chokidar from 'chokidar';
import ip from 'ip';
import path from 'path';
const address = ip.address();
let timeout;
let serverProcess: child_process.ChildProcess;

// start building
const buildProcess = child_process.spawn('npm', ['run', 'build'], {
  env: {
    ...process.env,
    LOCAL_IP: address,
  },
  stdio: [0, 1, 2],
});

startServerProcess();

// watch file change and restart server
const watcher = chokidar
  .watch([path.resolve(__dirname, './'), path.resolve(__dirname, '../web/common')])
  .on('add', startServerProcess)
  .on('change', startServerProcess)
  .on('unlink', startServerProcess);

function startServerProcess(f?: string) {
  clearTimeout(timeout);
  timeout = setTimeout(() => {
    if (f) {
      console.info(f + ' changed, restart server...');
开发者ID:whxaxes,项目名称:slither,代码行数:31,代码来源:dev.ts

示例7:

import * as Ip from 'ip';
import { Config } from './../share/config';

const host: string = `${Ip.address()}:${Config.PORT}`;

process.once('loaded', () => {
  global['appHost'] = host;
});
开发者ID:ARA-Tester,项目名称:ARA-Tester,代码行数:8,代码来源:preload.ts

示例8: EventEmitter

 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import {EventEmitter} from 'events';
import ip from 'ip';
import {ITrace} from './types';

const pid = process.pid;
const ipAddr = ip.address();

export const msg = new EventEmitter();

export const isDevEnv = process.env.NODE_ENV !== 'production';

/**
 * yes, just do nothing.
 */
export const noop = () => {};

/**
 * trace log
 * @param info
 */
export const trace = (obj: ITrace) => {
开发者ID:hufeng,项目名称:node-jsonrpc-dubbo,代码行数:31,代码来源:util.ts


注:本文中的ip.address函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。