npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

capture-private-ip

v0.0.5

Published

This library helps you capture private IP address of the machine using WebRTC in modern browsers like Chrome, Firefox, Edge and machine name and user name in legacy browsers like Internet Explorer 11.

Downloads

5

Readme

Capture Private IP Address

This library helps you capture private IP address of the machine using WebRTC in modern browsers like Chrome, Firefox, Edge and machine name and user name in legacy browsers like Internet Explorer 11.

This library was generated with Angular CLI version 9.0.7.

Supported Browser Versions

Chrome >= 83.x

Edge >= 83.x

Firefox >= 76.x

Internet Explorer 11.x

How to Use

Install the package using the command given below:

npm install --save capture-private-ip

Include following Javascripts in scripts array in your project's angular.json file, like below:

"scripts": [
              "node_modules/capture-private-ip/src/js/ie-machine-name-finder.js",
              "node_modules/capture-private-ip/src/js/modern-ip-finder.js"
            ]

Include the module CapturePrivateIpModule in you App module like below:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {CapturePrivateIpModule} from 'capture-private-ip';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    CapturePrivateIpModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Inject and use the service CapturePrivateIpService in your App component like below:

import { Component, OnInit } from '@angular/core';
import { CapturePrivateIpService } from 'capture-private-ip';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  title = 'test-capture-private-ip-lib';
  machineDetails : any;
  allIps : any;

  constructor(private ipService:CapturePrivateIpService)
  {

  }

  ngOnInit()
  {
    const isIE = /msie\s|trident\//i.test(window.navigator.userAgent);
    const isEdge = /edg\//i.test(window.navigator.userAgent);
    const isChrome = /Chrome\//i.test(window.navigator.userAgent);
    const isFirefox = /Firefox\//i.test(window.navigator.userAgent);
    if(isIE)
      this.machineDetails = this.ipService.fetchMachineNameOnInternetExplorer();
    
    if(isEdge || isChrome || isFirefox)  {
      this.ipService.fetchPrivateIpOnModernBrowsers();
      setTimeout(()=>{
        this.allIps = document.cookie;
      },200);
    }
  }
}

You can render private IP captured in your App Component like below:

<div style="text-align:center">
  <h1>
    Welcome to {{ title }}!
  </h1>
  <img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
  <div *ngIf="allIps">
    <pre>{{allIps}}</pre>
  </div>
  <div *ngIf="machineDetails">
    <pre>{{machineDetails.userName}}</pre>
    <pre>{{machineDetails.machineName}}</pre>
  </div>
</div>

Finally you need to set some browser flags/settings to disable annonymization of IP address and run ActiveX control:

  1. Open Chrome and in address bar type Chrome://flags

  2. In the search box type Anonymize local IPs exposed by WebRTC

  3. From the dropdown in result section, select the option Disabled

  4. Open Edge and in address bar type edge://flags/

  5. In the search box type Anonymize local IPs exposed by WebRTC

  6. From the dropdown in result section, select the option Disabled

  7. Open Firefox and in address bar type about:config

  8. Click on Accept Risk and Continue

  9. In the search bar type media.peerconnection.enabled and toggle it to set it true

  10. In the search bar type media.peerconnection.ice.obfuscate_host_addresses and toggle it to set it to false

  11. Open Internet Explorer 11.

  12. Open Internet Options by clicking the gear icon localted in top right.

  13. Click on Security tab.

  14. Click on Intranet tab.

  15. Click on Custom level button

  16. Scroll to the setting Initialize and script ActiveX controls not marked safe for scripting.

  17. Click the Enable button.

  18. Click Ok and come out.

Voila!! You are set to fetch private IPs and machine name on users machine where your site is being browsed.

Demo Private IP Capture

This Github repo demonstrates the use of this package.

Demo Private IP Capture