├── .gitignore ├── CONTRIBUTORS ├── yajsync-core ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── github │ │ │ └── perlundq │ │ │ └── yajsync │ │ │ ├── internal │ │ │ ├── package-info.java │ │ │ ├── io │ │ │ │ ├── package-info.java │ │ │ │ ├── FileViewNotFound.java │ │ │ │ ├── FileViewOpenFailed.java │ │ │ │ ├── FileViewException.java │ │ │ │ └── AutoDeletable.java │ │ │ ├── text │ │ │ │ ├── package-info.java │ │ │ │ └── TextConversionException.java │ │ │ ├── util │ │ │ │ ├── package-info.java │ │ │ │ ├── StatusResult.java │ │ │ │ ├── MemoryPolicy.java │ │ │ │ ├── ErrorPolicy.java │ │ │ │ ├── OverflowException.java │ │ │ │ ├── RuntimeInterruptException.java │ │ │ │ ├── ArgumentParsingError.java │ │ │ │ ├── Pair.java │ │ │ │ ├── Consts.java │ │ │ │ ├── Triple.java │ │ │ │ ├── MD5.java │ │ │ │ ├── Multimap.java │ │ │ │ ├── BitOps.java │ │ │ │ └── Rolling.java │ │ │ ├── channels │ │ │ │ ├── package-info.java │ │ │ │ ├── IndexDecoder.java │ │ │ │ ├── IndexEncoder.java │ │ │ │ ├── Bufferable.java │ │ │ │ ├── Taggable.java │ │ │ │ ├── MessageHandler.java │ │ │ │ ├── ChannelEOFException.java │ │ │ │ ├── ChannelException.java │ │ │ │ ├── Writable.java │ │ │ │ ├── Readable.java │ │ │ │ ├── RsyncOutChannel.java │ │ │ │ ├── AutoFlushableDuplexChannel.java │ │ │ │ ├── RsyncInChannel.java │ │ │ │ ├── AutoFlushableRsyncDuplexChannel.java │ │ │ │ ├── IndexEncoderImpl.java │ │ │ │ ├── MessageCode.java │ │ │ │ ├── IndexDecoderImpl.java │ │ │ │ ├── MessageHeader.java │ │ │ │ ├── BufferedDuplexChannel.java │ │ │ │ ├── TaggedOutputChannel.java │ │ │ │ ├── TaggedInputChannel.java │ │ │ │ └── Message.java │ │ │ ├── filelist │ │ │ │ └── package-info.java │ │ │ └── session │ │ │ │ ├── package-info.java │ │ │ │ ├── FilterMode.java │ │ │ │ ├── IoError.java │ │ │ │ ├── RsyncTask.java │ │ │ │ ├── RsyncCompatibilities.java │ │ │ │ ├── TransferPhase.java │ │ │ │ ├── SessionStatus.java │ │ │ │ ├── LocatableFileInfoImpl.java │ │ │ │ ├── SymlinkInfoImpl.java │ │ │ │ ├── LocatableDeviceInfoImpl.java │ │ │ │ ├── LocatableSymlinkInfoImpl.java │ │ │ │ ├── DeviceInfoImpl.java │ │ │ │ ├── ProtocolVersion.java │ │ │ │ ├── ConcurrentFilelist.java │ │ │ │ ├── Connection.java │ │ │ │ ├── TransmitFlags.java │ │ │ │ ├── FileInfoCache.java │ │ │ │ ├── Item.java │ │ │ │ ├── SessionStatistics.java │ │ │ │ ├── BasicFileAttributeManager.java │ │ │ │ ├── FileAttributeManager.java │ │ │ │ ├── IntegerCoder.java │ │ │ │ └── FileAttributeManagerFactory.java │ │ │ ├── attr │ │ │ ├── LocatableDeviceInfo.java │ │ │ ├── LocatableSymlinkInfo.java │ │ │ ├── SymlinkInfo.java │ │ │ ├── DeviceInfo.java │ │ │ ├── LocatableFileInfo.java │ │ │ ├── FileInfo.java │ │ │ ├── User.java │ │ │ ├── Group.java │ │ │ └── RsyncFileAttributes.java │ │ │ ├── server │ │ │ └── module │ │ │ │ ├── ModuleNotFoundException.java │ │ │ │ ├── ModuleSecurityException.java │ │ │ │ ├── Module.java │ │ │ │ ├── ModuleException.java │ │ │ │ ├── Modules.java │ │ │ │ ├── ModuleProvider.java │ │ │ │ ├── RestrictedModule.java │ │ │ │ └── RsyncAuthContext.java │ │ │ ├── RsyncException.java │ │ │ ├── RsyncProtocolException.java │ │ │ ├── RsyncSecurityException.java │ │ │ ├── AuthProvider.java │ │ │ ├── FileSelection.java │ │ │ └── Statistics.java │ └── test │ │ └── java │ │ └── com │ │ └── github │ │ └── perlundq │ │ └── yajsync │ │ ├── test │ │ └── ReadableByteBuffer.java │ │ └── util │ │ ├── PathOpsParamTest.java │ │ └── PathOpsTest.java └── pom.xml ├── yajsync-app ├── src │ ├── assembly │ │ └── assembly.xml │ └── main │ │ └── java │ │ └── com │ │ └── github │ │ └── perlundq │ │ └── yajsync │ │ ├── ui │ │ ├── IllegalUrlException.java │ │ ├── Main.java │ │ ├── RsyncUrls.java │ │ └── ConnInfo.java │ │ └── net │ │ ├── ServerChannel.java │ │ ├── ChannelFactory.java │ │ ├── ServerChannelFactory.java │ │ ├── SSLChannelFactory.java │ │ ├── StandardChannelFactory.java │ │ ├── DuplexByteChannel.java │ │ ├── StandardServerChannel.java │ │ ├── SSLServerChannel.java │ │ ├── StandardServerChannelFactory.java │ │ ├── SSLServerChannelFactory.java │ │ ├── SSLChannel.java │ │ └── StandardSocketChannel.java └── pom.xml ├── pom.xml └── CONTRIBUTING.md /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /build/ 3 | /doc/ 4 | /misc/ 5 | .classpath 6 | .project 7 | .settings/ 8 | target/ 9 | *~ 10 | *.iml 11 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file lists all individual contributors to yajsync 2 | Per Lundqvist 3 | Florian Sager 4 | David Pilato 5 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | Warning: all packages and classes below com.github.perlundq.yajsync.internal 3 | belong to yajsync's internal API only - do not use. 4 | */ 5 | package com.github.perlundq.yajsync.internal; 6 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/io/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | Warning: all packages and classes below com.github.perlundq.yajsync.internal 3 | belong to yajsync's internal API only - do not use. 4 | */ 5 | package com.github.perlundq.yajsync.internal.io; 6 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/text/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | Warning: all packages and classes below com.github.perlundq.yajsync.internal 3 | belong to yajsync's internal API only - do not use. 4 | */ 5 | package com.github.perlundq.yajsync.internal.text; 6 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | Warning: all packages and classes below com.github.perlundq.yajsync.internal 3 | belong to yajsync's internal API only - do not use. 4 | */ 5 | package com.github.perlundq.yajsync.internal.util; 6 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | Warning: all packages and classes below com.github.perlundq.yajsync.internal 3 | belong to yajsync's internal API only - do not use. 4 | */ 5 | package com.github.perlundq.yajsync.internal.channels; 6 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/filelist/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | Warning: all packages and classes below com.github.perlundq.yajsync.internal 3 | belong to yajsync's internal API only - do not use. 4 | */ 5 | package com.github.perlundq.yajsync.internal.filelist; 6 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | Warning: all packages and classes below com.github.perlundq.yajsync.internal 3 | belong to yajsync's internal API only - do not use. 4 | */ 5 | package com.github.perlundq.yajsync.internal.session; 6 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/StatusResult.java: -------------------------------------------------------------------------------- 1 | package com.github.perlundq.yajsync.internal.util; 2 | 3 | public class StatusResult 4 | { 5 | private final boolean _isOK; 6 | private final T _value; 7 | 8 | public StatusResult(boolean isOK, T value) 9 | { 10 | _isOK = isOK; 11 | _value = value; 12 | } 13 | 14 | public boolean isOK() 15 | { 16 | return _isOK; 17 | } 18 | 19 | public T value() 20 | { 21 | return _value; 22 | } 23 | } -------------------------------------------------------------------------------- /yajsync-core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | yajsync-parent 8 | com.github.perlundq 9 | 0.9.0-SNAPSHOT 10 | 11 | 12 | yajsync-core 13 | yajsync: Java rsync API 14 | 15 | 16 | -------------------------------------------------------------------------------- /yajsync-app/src/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | full 6 | 7 | jar 8 | 9 | false 10 | 11 | 12 | 13 | 14 | com.github.perlundq:yajsync-core 15 | com.github.perlundq:yajsync-app 16 | 17 | true 18 | true 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/FilterMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.internal.session; 18 | 19 | public enum FilterMode { NONE, SEND, RECEIVE } 20 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/attr/LocatableDeviceInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.attr; 18 | 19 | public interface LocatableDeviceInfo extends DeviceInfo, LocatableFileInfo {} 20 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/attr/LocatableSymlinkInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.attr; 18 | 19 | public interface LocatableSymlinkInfo extends SymlinkInfo, LocatableFileInfo {} 20 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/attr/SymlinkInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.attr; 18 | 19 | public interface SymlinkInfo extends FileInfo 20 | { 21 | String targetPathName(); 22 | } 23 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/attr/DeviceInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.attr; 18 | 19 | public interface DeviceInfo extends FileInfo 20 | { 21 | int major(); 22 | int minor(); 23 | } 24 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/attr/LocatableFileInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.attr; 18 | 19 | import java.nio.file.Path; 20 | 21 | public interface LocatableFileInfo extends FileInfo 22 | { 23 | Path path(); 24 | } 25 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/MemoryPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Whether or not to clear buffer when encoding/decoding text 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.util; 20 | 21 | public enum MemoryPolicy { ZERO, IGNORE } -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/ErrorPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Whether to return null or throw an exception when encoding/decoding 3 | * text 4 | * 5 | * Copyright (C) 2013, 2014 Per Lundqvist 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package com.github.perlundq.yajsync.internal.util; 21 | 22 | public enum ErrorPolicy { THROW, RETURN_NULL } -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/IndexDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Interface for rsync file list index decoding 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.channels; 20 | 21 | public interface IndexDecoder 22 | { 23 | int decodeIndex() throws ChannelException; 24 | } 25 | -------------------------------------------------------------------------------- /yajsync-app/src/main/java/com/github/perlundq/yajsync/ui/IllegalUrlException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2015 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.ui; 18 | 19 | @SuppressWarnings("serial") 20 | class IllegalUrlException extends Exception 21 | { 22 | public IllegalUrlException(String msg) 23 | { 24 | super(msg); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/IndexEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Interface for rsync file list index encoding 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.channels; 20 | 21 | public interface IndexEncoder 22 | { 23 | void encodeIndex(int index) throws ChannelException; 24 | } 25 | -------------------------------------------------------------------------------- /yajsync-app/src/main/java/com/github/perlundq/yajsync/net/ServerChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.net; 18 | 19 | import java.io.IOException; 20 | 21 | public interface ServerChannel extends AutoCloseable 22 | { 23 | DuplexByteChannel accept() throws IOException; 24 | @Override void close() throws IOException; 25 | } 26 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/Bufferable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Interface for bufferable channels 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.channels; 20 | 21 | public interface Bufferable extends Writable 22 | { 23 | void flush() throws ChannelException; 24 | int numBytesBuffered(); 25 | } 26 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/server/module/ModuleNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.server.module; 18 | 19 | @SuppressWarnings("serial") 20 | public class ModuleNotFoundException extends ModuleException 21 | { 22 | public ModuleNotFoundException(String message) 23 | { 24 | super(message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/server/module/ModuleSecurityException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.server.module; 18 | 19 | @SuppressWarnings("serial") 20 | public class ModuleSecurityException extends ModuleException 21 | { 22 | public ModuleSecurityException(String message) 23 | { 24 | super(message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /yajsync-app/src/main/java/com/github/perlundq/yajsync/net/ChannelFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.net; 18 | 19 | import java.io.IOException; 20 | 21 | public interface ChannelFactory 22 | { 23 | DuplexByteChannel open(String address, int remotePort, int contimeout, 24 | int timeout) 25 | throws IOException; 26 | } 27 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/Taggable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Interface for types with support for sending tagged rsync channel 3 | * messages 4 | * 5 | * Copyright (C) 2013, 2014 Per Lundqvist 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package com.github.perlundq.yajsync.internal.channels; 21 | 22 | public interface Taggable extends Bufferable 23 | { 24 | void putMessage(Message message) throws ChannelException; 25 | } 26 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/server/module/Module.java: -------------------------------------------------------------------------------- 1 | /* 2 | * representation of a rsync module 3 | * 4 | * Copyright (C) 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.server.module; 20 | 21 | public interface Module 22 | { 23 | String name(); 24 | String comment(); 25 | RestrictedPath restrictedPath(); 26 | boolean isReadable(); 27 | boolean isWritable(); 28 | } 29 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/io/FileViewNotFound.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception type for deferred IOException:s thrown from FileView 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.io; 20 | 21 | @SuppressWarnings("serial") 22 | public class FileViewNotFound extends FileViewOpenFailed 23 | { 24 | FileViewNotFound(String message) 25 | { 26 | super(message); 27 | } 28 | } -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/io/FileViewOpenFailed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception type for failing to open a Fileview due to an IOException 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.io; 20 | 21 | @SuppressWarnings("serial") 22 | public class FileViewOpenFailed extends FileViewException 23 | { 24 | FileViewOpenFailed(String message) 25 | { 26 | super(message); 27 | } 28 | } -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/OverflowException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception type thrown when failing to enlarge a buffer 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.util; 20 | 21 | @SuppressWarnings("serial") 22 | public class OverflowException extends RuntimeException 23 | { 24 | public OverflowException(String message) 25 | { 26 | super(message); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /yajsync-app/src/main/java/com/github/perlundq/yajsync/net/ServerChannelFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.net; 18 | 19 | import java.io.IOException; 20 | import java.net.InetAddress; 21 | 22 | public interface ServerChannelFactory 23 | { 24 | ServerChannelFactory setReuseAddress(boolean isReuseAddress); 25 | ServerChannel open(InetAddress address, int port, int timeout) 26 | throws IOException; 27 | } 28 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/server/module/ModuleException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.server.module; 18 | 19 | @SuppressWarnings("serial") 20 | public class ModuleException extends Exception 21 | { 22 | public ModuleException(String message) 23 | { 24 | super(message); 25 | } 26 | 27 | public ModuleException(Throwable t) 28 | { 29 | super(t); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/RuntimeInterruptException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * InterruptedException as an unchecked exception 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.util; 20 | 21 | @SuppressWarnings("serial") 22 | public class RuntimeInterruptException extends RuntimeException 23 | { 24 | public RuntimeInterruptException(Exception e) 25 | { 26 | super(e); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/MessageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Callback handlers called for handling of incoming rsync channel 3 | * messages except DATA 4 | * 5 | * Copyright (C) 2013, 2014 Per Lundqvist 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package com.github.perlundq.yajsync.internal.channels; 21 | 22 | import com.github.perlundq.yajsync.RsyncProtocolException; 23 | 24 | public interface MessageHandler 25 | { 26 | void handleMessage(Message message) throws RsyncProtocolException; 27 | } 28 | -------------------------------------------------------------------------------- /yajsync-app/src/main/java/com/github/perlundq/yajsync/net/SSLChannelFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.net; 18 | 19 | import java.io.IOException; 20 | 21 | public class SSLChannelFactory implements ChannelFactory 22 | { 23 | @Override 24 | public DuplexByteChannel open(String address, int port, int contimeout, int timeout) 25 | throws IOException 26 | { 27 | return SSLChannel.open(address, port, contimeout, timeout); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/RsyncException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync; 18 | 19 | /** 20 | * Signals that a generic rsync related error has occurred. 21 | */ 22 | @SuppressWarnings("serial") 23 | public class RsyncException extends Exception 24 | { 25 | public RsyncException(String msg) 26 | { 27 | super(msg); 28 | } 29 | 30 | public RsyncException(Throwable t) 31 | { 32 | super(t); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /yajsync-app/src/main/java/com/github/perlundq/yajsync/net/StandardChannelFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.net; 18 | 19 | import java.io.IOException; 20 | 21 | public class StandardChannelFactory implements ChannelFactory 22 | { 23 | @Override 24 | public DuplexByteChannel open(String address, int port, int contimeout, int timeout) 25 | throws IOException 26 | { 27 | return StandardSocketChannel.open(address, port, contimeout, timeout); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/IoError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Rsync network I/O error status flag 3 | * 4 | * Copyright (C) 1996-2011 by Andrew Tridgell, Wayne Davison, and others 5 | * Copyright (C) 2013, 2014 Per Lundqvist 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package com.github.perlundq.yajsync.internal.session; 21 | 22 | final class IoError 23 | { 24 | private IoError() {} 25 | 26 | public static final int GENERAL = 1 << 0; 27 | public static final int VANISHED = 1 << 1; 28 | public static final int TRANSFER = 1 << 31; 29 | } 30 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/ChannelEOFException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception type for channel EOF 3 | * 4 | * Copyright (C) 2013, 2014, 2016 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.channels; 20 | 21 | @SuppressWarnings("serial") 22 | public class ChannelEOFException extends ChannelException 23 | { 24 | public ChannelEOFException(String message) 25 | { 26 | super(message); 27 | } 28 | 29 | public ChannelEOFException(Exception e) 30 | { 31 | super(e); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/io/FileViewException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception type for deferred IOException:s thrown during FileView reading 3 | * 4 | * Copyright (C) 2013, 2014, 2016 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.io; 20 | 21 | @SuppressWarnings("serial") 22 | public class FileViewException extends Exception 23 | { 24 | FileViewException(Exception e) 25 | { 26 | super(e); 27 | } 28 | 29 | FileViewException(String message) 30 | { 31 | super(message); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/ArgumentParsingError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception type for errors encountered during argument parsing 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.util; 20 | 21 | @SuppressWarnings("serial") 22 | public class ArgumentParsingError extends Exception 23 | { 24 | public ArgumentParsingError(String string) 25 | { 26 | super(string); 27 | } 28 | 29 | public ArgumentParsingError(Exception e) 30 | { 31 | super(e); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2015 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.internal.util; 18 | 19 | public final class Pair 20 | { 21 | private final T _first; 22 | private final V _second; 23 | 24 | public Pair(T first, V second) 25 | { 26 | _first = first; 27 | _second = second; 28 | } 29 | 30 | public T first() 31 | { 32 | return _first; 33 | } 34 | 35 | public V second() 36 | { 37 | return _second; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /yajsync-app/src/main/java/com/github/perlundq/yajsync/net/DuplexByteChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014, 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.net; 18 | 19 | import java.net.InetAddress; 20 | import java.nio.channels.ReadableByteChannel; 21 | import java.nio.channels.WritableByteChannel; 22 | import java.security.Principal; 23 | import java.util.Optional; 24 | 25 | public interface DuplexByteChannel extends ReadableByteChannel, 26 | WritableByteChannel 27 | { 28 | InetAddress peerAddress(); 29 | Optional peerPrincipal(); 30 | } 31 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/text/TextConversionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception type for errors encountered during character encoding 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.text; 20 | 21 | 22 | @SuppressWarnings("serial") 23 | public class TextConversionException extends RuntimeException 24 | { 25 | public TextConversionException(String description) 26 | { 27 | super(description); 28 | } 29 | 30 | public TextConversionException(Exception e) 31 | { 32 | super(e); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/ChannelException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception type for channel IOException:s 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.channels; 20 | 21 | import com.github.perlundq.yajsync.RsyncException; 22 | 23 | @SuppressWarnings("serial") 24 | public class ChannelException extends RsyncException 25 | { 26 | public ChannelException(String message) 27 | { 28 | super(message); 29 | } 30 | 31 | public ChannelException(Exception e) 32 | { 33 | super(e); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/RsyncTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.internal.session; 18 | 19 | import java.util.concurrent.Callable; 20 | 21 | import com.github.perlundq.yajsync.RsyncException; 22 | import com.github.perlundq.yajsync.internal.channels.ChannelException; 23 | 24 | public interface RsyncTask extends Callable 25 | { 26 | @Override 27 | Boolean call() throws RsyncException,InterruptedException; 28 | 29 | boolean isInterruptible(); 30 | void closeChannel() throws ChannelException; 31 | } -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/RsyncProtocolException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception type for general rsync protocol errors 3 | * 4 | * Copyright (C) 2013, 2014, 2016 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync; 20 | 21 | /** 22 | * Signals that a rsync protocol error has occurred. 23 | */ 24 | @SuppressWarnings("serial") 25 | public class RsyncProtocolException extends RsyncException 26 | { 27 | public RsyncProtocolException(String msg) 28 | { 29 | super(msg); 30 | } 31 | 32 | public RsyncProtocolException(Exception e) 33 | { 34 | super(e); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/Consts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Constants 3 | * 4 | * Copyright (C) 2013-2015 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.util; 20 | 21 | public final class Consts 22 | { 23 | public static final int DEFAULT_UMASK = 0022; 24 | public static final int MAX_BUF_SIZE = 1024; 25 | public static final int SIZE_BYTE = 1; 26 | public static final int SIZE_CHAR = 2; 27 | public static final int SIZE_SHORT = 2; 28 | public static final int SIZE_INT = 4; 29 | public static final int SIZE_LONG = 8; 30 | 31 | private Consts() {} 32 | } 33 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/Writable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Interface for types support sending rsync basic data to peer 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.channels; 20 | 21 | import java.nio.ByteBuffer; 22 | 23 | public interface Writable 24 | { 25 | void put(ByteBuffer src) throws ChannelException; 26 | void put(byte[] src, int offset, int length) throws ChannelException; 27 | void putByte(byte b) throws ChannelException; 28 | void putChar(char c) throws ChannelException; 29 | void putInt(int i) throws ChannelException; 30 | } -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/RsyncSecurityException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Exception type for rsync security errors 3 | * 4 | * Copyright (C) 2013, 2014, 2016 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync; 20 | 21 | /** 22 | * Signals that an error which could compromise the integrity of yajsync has 23 | * occurred. 24 | */ 25 | @SuppressWarnings("serial") 26 | public class RsyncSecurityException extends RsyncException 27 | { 28 | public RsyncSecurityException(String message) 29 | { 30 | super(message); 31 | } 32 | 33 | public RsyncSecurityException(Exception e) 34 | { 35 | super(e); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/RsyncCompatibilities.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Rsync additional protocol support flags used during initial 3 | * handshake 4 | * 5 | * Copyright (C) 1996-2011 by Andrew Tridgell, Wayne Davison, and others 6 | * Copyright (C) 2013, 2014 Per Lundqvist 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | */ 21 | package com.github.perlundq.yajsync.internal.session; 22 | 23 | final class RsyncCompatibilities 24 | { 25 | private RsyncCompatibilities() {} 26 | public static final byte CF_INC_RECURSE = 1 << 0; 27 | public static final byte CF_SYMLINK_TIMES = 1 << 1; 28 | public static final byte CF_SYMLINK_ICONV = 1 << 2; 29 | public static final byte CF_SAFE_FLIST = 1 << 3; 30 | } 31 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/Triple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2015 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.internal.util; 18 | 19 | public final class Triple 20 | { 21 | private final S _first; 22 | private final T _second; 23 | private final U _third; 24 | 25 | public Triple(S first, T second, U third) 26 | { 27 | _first = first; 28 | _second = second; 29 | _third = third; 30 | } 31 | 32 | public S first() 33 | { 34 | return _first; 35 | } 36 | 37 | public T second() 38 | { 39 | return _second; 40 | } 41 | 42 | public U third() 43 | { 44 | return _third; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/TransferPhase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Sender and Receiver connection state 3 | * 4 | * Copyright (C) 2016 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.session; 20 | 21 | enum TransferPhase 22 | { 23 | TRANSFER, TEAR_DOWN_1, TEAR_DOWN_2, STOP; 24 | 25 | public TransferPhase next() 26 | { 27 | switch (this) { 28 | case TRANSFER: 29 | return TEAR_DOWN_1; 30 | case TEAR_DOWN_1: 31 | return TEAR_DOWN_2; 32 | case TEAR_DOWN_2: 33 | return STOP; 34 | case STOP: 35 | return STOP; 36 | default: 37 | throw new IllegalStateException(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/AuthProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * Provides a user name and password when the client authenticates with a server 23 | * that has requested rsync authentication for an rsync module. 24 | */ 25 | public interface AuthProvider 26 | { 27 | /** 28 | * @return the user name to be authenticated as. 29 | * @throws IOException 30 | */ 31 | String getUser() throws IOException; 32 | 33 | /** 34 | * @return password as a char array. The array will be zeroed out as quickly 35 | * as possible once it has been used. 36 | * @throws IOException 37 | */ 38 | char[] getPassword() throws IOException; 39 | } 40 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/SessionStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rsync peer handshake session status 3 | * 4 | * Copyright (C) 1996-2011 by Andrew Tridgell, Wayne Davison, and others 5 | * Copyright (C) 2013, 2014 Per Lundqvist 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package com.github.perlundq.yajsync.internal.session; 21 | 22 | public enum SessionStatus 23 | { 24 | OK("@RSYNCD: OK"), 25 | EXIT("@RSYNCD: EXIT"), 26 | ERROR("@ERROR"), 27 | AUTHREQ("@RSYNCD: AUTHREQD "); 28 | 29 | private final String _repr; 30 | 31 | SessionStatus(String s) 32 | { 33 | _repr = s; 34 | } 35 | 36 | boolean matches(String s) 37 | { 38 | return s.startsWith(_repr); 39 | } 40 | 41 | @Override 42 | public String toString() 43 | { 44 | return _repr; 45 | } 46 | } -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/Readable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Interface for types support reading rsync basic data from peer 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.channels; 20 | 21 | import java.nio.ByteBuffer; 22 | 23 | public interface Readable 24 | { 25 | // NOTE: ByteBuffer.position() might very well be > 0, so calling rewind may lead to 26 | // unexpected behavior. Use mark and reset instead 27 | ByteBuffer get(int numBytes) throws ChannelException; 28 | void get(byte[] dst, int offset, int length) throws ChannelException; 29 | byte getByte() throws ChannelException; 30 | char getChar() throws ChannelException; 31 | int getInt() throws ChannelException; 32 | void skip(int numBytes) throws ChannelException; 33 | } -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/io/AutoDeletable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Automatically delete a file on close 3 | * 4 | * Copyright (C) 2015 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.io; 20 | 21 | import java.io.IOException; 22 | import java.nio.file.Files; 23 | import java.nio.file.Path; 24 | 25 | public class AutoDeletable implements AutoCloseable 26 | { 27 | private final Path _path; 28 | 29 | public AutoDeletable(Path path) 30 | { 31 | _path = path; 32 | } 33 | 34 | public Path path() 35 | { 36 | return _path; 37 | } 38 | 39 | @Override 40 | public String toString() 41 | { 42 | return _path.toString(); 43 | } 44 | 45 | @Override 46 | public void close() throws IOException 47 | { 48 | Files.deleteIfExists(_path); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /yajsync-app/src/main/java/com/github/perlundq/yajsync/net/StandardServerChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.net; 18 | 19 | import java.io.IOException; 20 | import java.nio.channels.ServerSocketChannel; 21 | 22 | public class StandardServerChannel implements ServerChannel 23 | { 24 | private final ServerSocketChannel _sock; 25 | private final int _timeout; 26 | 27 | public StandardServerChannel(ServerSocketChannel sock, int timeout) 28 | { 29 | _sock = sock; 30 | _timeout = timeout; 31 | } 32 | 33 | @Override 34 | public void close() throws IOException 35 | { 36 | _sock.close(); 37 | } 38 | 39 | @Override 40 | public StandardSocketChannel accept() throws IOException 41 | { 42 | return new StandardSocketChannel(_sock.accept(), _timeout); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /yajsync-app/src/main/java/com/github/perlundq/yajsync/net/SSLServerChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.net; 18 | 19 | import java.io.IOException; 20 | 21 | import javax.net.ssl.SSLServerSocket; 22 | import javax.net.ssl.SSLSocket; 23 | 24 | public class SSLServerChannel implements ServerChannel 25 | { 26 | private final SSLServerSocket _sslSocket; 27 | private final int _timeout; 28 | 29 | public SSLServerChannel(SSLServerSocket sock, int timeout) 30 | { 31 | _sslSocket = sock; 32 | _timeout = timeout; 33 | } 34 | 35 | @Override 36 | public void close() throws IOException 37 | { 38 | _sslSocket.close(); 39 | } 40 | 41 | @Override 42 | public SSLChannel accept() throws IOException 43 | { 44 | return new SSLChannel((SSLSocket) _sslSocket.accept(), _timeout); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/LocatableFileInfoImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.internal.session; 18 | 19 | import java.nio.file.Path; 20 | 21 | import com.github.perlundq.yajsync.attr.LocatableFileInfo; 22 | import com.github.perlundq.yajsync.attr.RsyncFileAttributes; 23 | 24 | class LocatableFileInfoImpl extends FileInfoImpl implements LocatableFileInfo 25 | { 26 | private final Path _path; 27 | 28 | LocatableFileInfoImpl(String pathName, byte[] pathNameBytes, 29 | RsyncFileAttributes attrs, Path path) 30 | { 31 | super(pathName, pathNameBytes, attrs); 32 | assert path != null; 33 | assert path.isAbsolute(); 34 | _path = path; 35 | } 36 | 37 | @Override 38 | public Path path() 39 | { 40 | return _path; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/SymlinkInfoImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.internal.session; 18 | 19 | import com.github.perlundq.yajsync.attr.RsyncFileAttributes; 20 | import com.github.perlundq.yajsync.attr.SymlinkInfo; 21 | 22 | class SymlinkInfoImpl extends FileInfoImpl implements SymlinkInfo 23 | { 24 | private final String _targetPathName; 25 | 26 | public SymlinkInfoImpl(String pathName, byte[] pathNameBytes, 27 | RsyncFileAttributes attrs, String targetPathName) 28 | { 29 | super(pathName, pathNameBytes, attrs); 30 | assert targetPathName != null; 31 | assert attrs().isSymbolicLink(); 32 | _targetPathName = targetPathName; 33 | } 34 | 35 | @Override 36 | public String targetPathName() 37 | { 38 | return _targetPathName; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/RsyncOutChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Rsync Channel with support for sending tagged rsync Messages to 3 | * peer + file list index encoding 4 | * 5 | * Copyright (C) 2013, 2014 Per Lundqvist 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | package com.github.perlundq.yajsync.internal.channels; 21 | 22 | import java.nio.channels.WritableByteChannel; 23 | 24 | public class RsyncOutChannel extends TaggedOutputChannel implements IndexEncoder 25 | { 26 | private final IndexEncoder _indexEncoder; 27 | 28 | public RsyncOutChannel(WritableByteChannel sock) 29 | { 30 | super(sock); 31 | _indexEncoder = new IndexEncoderImpl(this); 32 | } 33 | 34 | public RsyncOutChannel(WritableByteChannel sock, int bufferSize) 35 | { 36 | super(sock, bufferSize); 37 | _indexEncoder = new IndexEncoderImpl(this); 38 | } 39 | 40 | @Override 41 | public void encodeIndex(int index) throws ChannelException 42 | { 43 | _indexEncoder.encodeIndex(index); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/LocatableDeviceInfoImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.internal.session; 18 | 19 | import java.nio.file.Path; 20 | 21 | import com.github.perlundq.yajsync.attr.LocatableDeviceInfo; 22 | import com.github.perlundq.yajsync.attr.RsyncFileAttributes; 23 | 24 | class LocatableDeviceInfoImpl extends DeviceInfoImpl 25 | implements LocatableDeviceInfo 26 | { 27 | private final Path _path; 28 | 29 | public LocatableDeviceInfoImpl(String pathName, byte[] pathNameBytes, 30 | RsyncFileAttributes attrs, 31 | int major, int minor, Path path) 32 | { 33 | super(pathName, pathNameBytes, attrs, major, minor); 34 | assert path != null; 35 | assert path.isAbsolute(); 36 | _path = path; 37 | } 38 | 39 | @Override 40 | public Path path() 41 | { 42 | return _path; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/LocatableSymlinkInfoImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.internal.session; 18 | 19 | import java.nio.file.Path; 20 | 21 | import com.github.perlundq.yajsync.attr.LocatableSymlinkInfo; 22 | import com.github.perlundq.yajsync.attr.RsyncFileAttributes; 23 | 24 | 25 | class LocatableSymlinkInfoImpl extends SymlinkInfoImpl 26 | implements LocatableSymlinkInfo 27 | { 28 | private final Path _path; 29 | 30 | LocatableSymlinkInfoImpl(String pathName, byte[] pathNameBytes, 31 | RsyncFileAttributes attrs, String targetPathName, 32 | Path path) 33 | { 34 | super(pathName, pathNameBytes, attrs, targetPathName); 35 | assert path != null; 36 | assert path.isAbsolute(); 37 | _path = path; 38 | } 39 | 40 | @Override 41 | public Path path() 42 | { 43 | return _path; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/util/MD5.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MD5 utility routines 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.util; 20 | 21 | import java.security.MessageDigest; 22 | import java.security.NoSuchAlgorithmException; 23 | 24 | public final class MD5 25 | { 26 | private static final String MD5_NAME = "MD5"; 27 | 28 | private MD5() {} 29 | 30 | public static MessageDigest newInstance() 31 | { 32 | try { 33 | return MessageDigest.getInstance(MD5_NAME); 34 | } catch (NoSuchAlgorithmException e) { 35 | throw new RuntimeException(e); // support for MD5 is required so this should not happen 36 | } 37 | } 38 | 39 | public static String md5DigestToString(byte[] digestBuf) 40 | { 41 | StringBuffer sb = new StringBuffer(); 42 | for (int i = 0; i < digestBuf.length; i++) { 43 | sb.append(Integer.toHexString(0xFF & digestBuf[i])); 44 | } 45 | return sb.toString(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/FileSelection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013-2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync; 18 | 19 | /** 20 | * An rsync transfer handles the initial list of file arguments sent by the 21 | * client in three different ways: 1. transfer the initial files exactly but 22 | * exclude all directories 2. transfer the initial files but also recurse into 23 | * directories 3. transfer the initial files but also transfer the contents 24 | * of any dot directories (i.e. the name ends with a trailing slash "dir/"' or a 25 | * slash followed by one dot "dir/." 26 | */ 27 | public enum FileSelection 28 | { 29 | /** 30 | * Transfer the initial client file list literally while excluding 31 | * directories. 32 | */ 33 | EXACT, 34 | 35 | /** 36 | * Transfer the initial client file list but also recurse into directories. 37 | */ 38 | RECURSE, 39 | 40 | /** 41 | * Transfer the initial client file list and the contents of any dot 42 | * directories. 43 | */ 44 | TRANSFER_DIRS 45 | } 46 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/server/module/Modules.java: -------------------------------------------------------------------------------- 1 | /* 2 | * A handle for all the modules available to a given Principal. 3 | * 4 | * Copyright (C) 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.server.module; 20 | 21 | public interface Modules 22 | { 23 | /** 24 | * @return a Module directly available to the principal or a 25 | * RestrictedModule in case further authentication is required 26 | * (using rsync challenge response protocol). 27 | * @throws ModuleSecurityException if principal should be denied access to 28 | * this module. 29 | * @throws ModuleException for any other errors that is expected to be 30 | * handled. 31 | */ 32 | Module get(String moduleName) throws ModuleException; 33 | 34 | /** 35 | * @return an iterable over all modules available to the principal connected 36 | * to this instance. Any module should be an instance of 37 | * RestrictedModule if further authentication is required. 38 | */ 39 | Iterable all(); 40 | } 41 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/session/DeviceInfoImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.internal.session; 18 | 19 | import com.github.perlundq.yajsync.attr.RsyncFileAttributes; 20 | import com.github.perlundq.yajsync.attr.DeviceInfo; 21 | 22 | class DeviceInfoImpl extends FileInfoImpl implements DeviceInfo 23 | { 24 | private final int _major; 25 | private final int _minor; 26 | 27 | DeviceInfoImpl(String pathName, byte[] pathNameBytes, 28 | RsyncFileAttributes attrs, int major, int minor) 29 | { 30 | super(pathName, pathNameBytes, attrs); 31 | assert attrs.isBlockDevice() || attrs.isCharacterDevice() || 32 | attrs.isFifo() || attrs.isSocket(); 33 | assert major >= 0; 34 | assert minor >= 0; 35 | _major = major; 36 | _minor = minor; 37 | } 38 | 39 | @Override 40 | public int major() 41 | { 42 | return _major; 43 | } 44 | 45 | @Override 46 | public int minor() 47 | { 48 | return _minor; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/attr/FileInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Per Lundqvist 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.perlundq.yajsync.attr; 18 | 19 | /** 20 | * A class containing generic file information for any type of file (regular, 21 | * directory, symbolic link or device file). 22 | * 23 | * Warning: not designed to be implemented or extended externally. 24 | * 25 | * Use attrs() to determine the actual file type. If possible, a more specific 26 | * subtype will be used, representing symbolic links (SymlinkInfo) and device 27 | * files (DeviceInfo) respectively. But in some circumstances a symbolic link or 28 | * device file might be represented as a regular FileInfo - if it is a symlink 29 | * and lacks information about symlink target or if it is a device file and 30 | * lacks information about major and minor number. 31 | * 32 | * Also, if the file has a local path representation, an as specific as possible 33 | * instance of LocatableFileInfo will be used. 34 | */ 35 | public interface FileInfo extends Comparable 36 | { 37 | RsyncFileAttributes attrs(); 38 | String pathName(); 39 | } 40 | -------------------------------------------------------------------------------- /yajsync-app/src/main/java/com/github/perlundq/yajsync/ui/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * A rsync client/server command line implementation 3 | * 4 | * Copyright (C) 2016 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.ui; 20 | 21 | import java.io.IOException; 22 | import java.util.Arrays; 23 | 24 | public class Main 25 | { 26 | public static void main(String args[]) throws IOException, 27 | InterruptedException 28 | { 29 | String helpText = "the first argument should be either \"client\" or " + 30 | "\"server\""; 31 | if (args.length == 0) { 32 | throw new IllegalArgumentException(helpText); 33 | } 34 | 35 | String[] args2 = Arrays.copyOfRange(args, 1, args.length); 36 | if (args[0].equals("client")) { 37 | int rc = new YajsyncClient().start(args2); 38 | System.exit(rc); 39 | } else if (args[0].equals("server")) { 40 | int rc = new YajsyncServer().start(args2); 41 | System.exit(rc); 42 | } else { 43 | throw new IllegalArgumentException(helpText); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/AutoFlushableDuplexChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Automatically flush output channel for read operations 3 | * 4 | * Copyright (C) 2013, 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.internal.channels; 20 | 21 | import java.nio.ByteBuffer; 22 | 23 | public class AutoFlushableDuplexChannel extends BufferedDuplexChannel 24 | { 25 | public AutoFlushableDuplexChannel(Readable readable, Bufferable writable) 26 | { 27 | super(readable, writable); 28 | } 29 | 30 | @Override 31 | public ByteBuffer get(int numBytes) throws ChannelException 32 | { 33 | flush(); 34 | return super.get(numBytes); 35 | } 36 | 37 | @Override 38 | public byte getByte() throws ChannelException 39 | { 40 | flush(); 41 | return super.getByte(); 42 | } 43 | 44 | @Override 45 | public char getChar() throws ChannelException 46 | { 47 | flush(); 48 | return super.getChar(); 49 | } 50 | 51 | @Override 52 | public int getInt() throws ChannelException 53 | { 54 | flush(); 55 | return super.getInt(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /yajsync-app/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | yajsync-parent 8 | com.github.perlundq 9 | 0.9.0-SNAPSHOT 10 | 11 | 12 | yajsync-app 13 | yajsync: Java rsync client/server 14 | 15 | 16 | 17 | com.github.perlundq 18 | yajsync-core 19 | 0.9.0-SNAPSHOT 20 | 21 | 22 | 23 | 24 | 25 | 26 | maven-assembly-plugin 27 | 28 | 29 | 30 | 31 | yajsync-app/src/assembly/assembly.xml 32 | 33 | 34 | 35 | 36 | com.github.perlundq.yajsync.ui.Main 37 | 38 | 39 | 40 | 41 | 42 | 43 | package 44 | 45 | single 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/internal/channels/RsyncInChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Rsync Channel with support for tagged rsync Messages sent from peer 3 | * and automatically prefetching of available amount + file list index 4 | * decoding 5 | * 6 | * Copyright (C) 2013, 2014 Per Lundqvist 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | */ 21 | package com.github.perlundq.yajsync.internal.channels; 22 | 23 | import java.nio.channels.ReadableByteChannel; 24 | 25 | public class RsyncInChannel extends PrefetchedTaggedInputChannel 26 | implements IndexDecoder 27 | { 28 | private final IndexDecoder _indexDecoder; 29 | 30 | public RsyncInChannel(ReadableByteChannel sock, MessageHandler handler) 31 | { 32 | super(sock, handler); 33 | _indexDecoder = new IndexDecoderImpl(this); 34 | 35 | } 36 | 37 | public RsyncInChannel(ReadableByteChannel sock, MessageHandler handler, 38 | int bufferSize) 39 | { 40 | super(sock, handler, bufferSize); 41 | _indexDecoder = new IndexDecoderImpl(this); 42 | 43 | } 44 | 45 | @Override 46 | public int decodeIndex() throws ChannelException 47 | { 48 | return _indexDecoder.decodeIndex(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /yajsync-core/src/main/java/com/github/perlundq/yajsync/server/module/ModuleProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Plugin-based module provider 3 | * 4 | * Copyright (C) 2014 Per Lundqvist 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package com.github.perlundq.yajsync.server.module; 20 | 21 | import java.net.InetAddress; 22 | import java.security.Principal; 23 | import java.util.Collection; 24 | import java.util.ServiceLoader; 25 | 26 | import com.github.perlundq.yajsync.internal.util.Option; 27 | 28 | public abstract class ModuleProvider 29 | { 30 | public static ModuleProvider getDefault() 31 | { 32 | ServiceLoader loader = 33 | ServiceLoader.load(ModuleProvider.class); 34 | for (ModuleProvider provider : loader) { 35 | return provider; 36 | } 37 | return new Configuration.Reader(); 38 | } 39 | 40 | public abstract Collection